forum

Home / DeveloperSection / Forums / How to Retrieving data from sql server and adding it to arraylist

How to Retrieving data from sql server and adding it to arraylist

Takeshi Okada 1823 21-Jan-2015

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()


Updated on 21-Jan-2015

Can you answer this question?


Answer

1 Answers

Liked By