title: Error Hexadecimal value 0x00 is a invalid character while sending a datatable in XML format through a LAN
body: <p>HI i am quite new to NET programming. I had to develop an application where the client needs to access a server through a LAN, and receive data from a remote MS ACCESS database. The communication is successful and the server is sending the data table in XML format. How ever when the client receives the string and try to convert it to XML and fill a datagridview, it gives an error </p>
  
  <blockquote>
    <p>"Hexadecimal value 0x00 is a invalid character"</p>
  </blockquote>
  
  <p>Any help solving this would be appreciated. I used both ASCII encoding and UTF-8 encoding but both didn't work.</p>
  
  <p>This is the client sending the request</p>
  
  <pre><code>    Dim client As New Net.Sockets.TcpClient
      Dim stream As NetworkStream = Nothing
      sql = "Select * from Roll "
  
      client.Connect("127.0.0.1", 3000)
      stream = client.GetStream
      Dim sendbytes() As Byte = Encoding.ASCII.GetBytes(sql)
      stream.Write(sendbytes, 0, sendbytes.Length)
  </code></pre>
  
  <p>And then the server receives it and run the query on database and send the datatable over the LAN connection</p>
  
  <pre><code>        client = server.AcceptTcpClient
          stream = client.GetStream
          Dim rvcBytes(client.ReceiveBufferSize) As Byte
          stream.Read(rvcBytes, 0, client.ReceiveBufferSize)
          Dim recive As String = Encoding.ASCII.GetString(rvcBytes)
  
  
      Try 'lotNumberFrom &amp; " and LotNumber " &amp; lotNumberTo
  
  
          cmd = New OleDbCommand(recive, con)
          '  MsgBox(recive)
          ds.Clear()
  
          adapter.SelectCommand = cmd
          adapter.Fill(ds, "Batch data")
  
          Dim writer As New System.IO.StringWriter
          ds.Tables("Batch data").WriteXml(writer, True)
  
          ' MsgBox(writer.ToString)
          Dim sendbytes() As Byte = Encoding.ASCII.GetBytes(writer.ToString)
          stream.Write(sendbytes, 0, sendbytes.Length)
  
  
  
  
  
      Catch ex As Exception
          MsgBox(ex.ToString)
      End Try
  </code></pre>
  
  <p>Then the client recieves it and tries to fill the datagridview. Thats where the problem occurs.</p>
  
  <pre><code>    Dim rvcBytes(client.ReceiveBufferSize) As Byte
      stream.Read(rvcBytes, 0, client.ReceiveBufferSize)
      Dim recive As String = Encoding.ASCII.GetString(rvcBytes)
      Dim dsa As New DataSet
  
  
  
      dsa.ReadXml(New XmlTextReader(New StringReader(recive)))
      DataGridView1.DataSource = dsa.Tables(0)
  
      client.Close()
  </code></pre>