title: ADODB RecordSet to String() in VB.NET
body: <p>I found this post which could help me in my project:</p>
  
  <p><a href="https://stackoverflow.com/questions/33157320/adodb-recordset-to-string-variable-vba">ADODB RecordSet to string variable VBA</a></p>
  
  <p>I want to adapt it to VB.NET instead of VBA, but it does not work.</p>
  
  <p>My goal is to create a String() using SQL. To give you an idea how the string would look like if hard coded, this is how we do it:</p>
  
  <pre><code>Public Sub New()
  InitializeComponent()
  strValue = New String() {"10051", "65658", "25689" etc... }
  End Sub
  
  
  
  **'My actual code is as follows:**
  
  Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) 
  Handles MyBase.Load
  
  Dim Connection1 As New ADODB.Connection
  Dim Connection1 As New ADODB.Connection
  Dim RecordSet1 As New ADODB.Recordset
  Dim SqlQuery1 As String, ConnectionString1 As String
  Dim strValue As String()
  
  SqlQuery1 = "Select ItemCode From OITM"
  ConnectionString1 = "Driver=SQL Server;Server=Myserver; Database=MyDbase; 
  User Id = sa; Password= 12345"
  Connection1.Open(ConnectionString1)
  RecordSet1 = New ADODB.Recordset
  RecordSet1.Open(SqlQuery1, Connection1)
  strValue = TryCast(RecordSet1.Fields("ItemCode").Value, String())
  
  Do While RecordSet1.EOF = False
  strValue = TryCast(RecordSet1.Fields("ItemCode").Value, String())
  
  MsgBox(strValue)
  RecordSet1.MoveNext()
  Loop
  </code></pre>
  
  <p>I expect the MsbBox to show the ItemCode at each looping, and building up the whole (very long) string. But it shows blank.</p>
  
  <p>I read that probably EOF does not work in VB .NET.</p>
  
  <p>What must I do?</p>