I am trying to retrieve data from the sql server and store it in an arraylist using vb.net but it is taking only one value and exiting while statement. I want to skip first 3 columns of the sql server table and start reading from 4th column.
Dim arr10 As New ArrayList
Dim i3 As Integer
i3 = 3
con.ConnectionString = "Data Source='" + System.Net.Dns.GetHostName + "'; Initial Catalog=hrmdb; Integrated Security=True"
con.Open()
Dim q1 As String = "SELECT * from empsal where emplycode='" + s2.ToString + "'"
Dim cm1 = New SqlCommand(q1, con)
Dim dr1 As SqlDataReader = cm1.ExecuteReader()
While dr1.Read()
arr10.Add(dr1(i3).ToString)
i3 = i3 + 1
End While
dr1.Close()
con.Close()
Anonymous User
21-Jan-2015While dr1.Read()
For i As Integer = 3 to CType(dr1, IDataRecord).FieldCount - 1
arr10.Add(dr1(i).ToString)
Next
End While