title: Reading String from TwinCAT PLC using ADS.NET returns ???? after data
body: <p>I'm trying to read String data from TwinCAT PLC using WinForm and ADS.NET. I based my code from <a href="https://infosys.beckhoff.com/english.php?content=../content/1033/tcsample_bdelphi/html/TcAdsNET_Delphi_Sample04.htm&amp;id=" rel="nofollow noreferrer">their sample codes</a>.
  Writing the string into the console shows my data as: "123456????????????????????????".
  I can use a textbox and it will show and save "123456" but I want to save it directly without using textboxes.</p>
  
  <p>What am I doing wrong? Or is there something missing from my code?</p>
  
  <p>Thanks!</p>
  
  <p>Additional info:</p>
  
  <p>(I'm trying to save the data into a DB):</p>
  
  <p><img src="https://i.stack.imgur.com/w4i9D.png" alt="Error message"></p>
  
  <p>Code:</p>
  
  <pre><code>private String readPLCData(String variableHandle)
          {
              int length;
              string text;
              AdsStream dataStream;
              BinaryReader reader;
              try
              {
                  varHandle = adsClient.CreateVariableHandle(variableHandle);
                  // length of the stream = length of string in sps + 1
                  dataStream = new AdsStream(31);
                  reader = new BinaryReader(dataStream, System.Text.Encoding.ASCII);
                  length = adsClient.Read(varHandle, dataStream);
                  text = new string(reader.ReadChars(length));
                  return text;
              }
              catch (Exception err)
              {
                  MessageBox.Show(err.Message);
                  return null;
              }
          }
  </code></pre>