List in Vb.net Sqldatareader

747 views Asked by At

Is there a way that list can be applied to this code? In terms of providing the textboxes and the datareader items.

Dim sConnection As String = "server=(local);uid=sa;pwd=PassWord;database=DatabaseName"
Using Con As New SqlConnection(sConnection)
    Con.Open()
    Using Com As New SqlCommand("Select * From tablename", Con)
        Using RDR = Com.ExecuteReader()
            If RDR.HasRows Then
                Do While RDR.Read
                    txtName.Text = RDR.Item("Name").ToString()
                Loop
            End If
        End Using
    End Using
    Con.Close()
End Using
1

There are 1 answers

4
b3r3ch1t On
Dim sConnection As String = "server=(local);uid=sa;pwd=PassWord;database=DatabaseName"
Using Con As New SqlConnection(sConnection)
Con.Open()
Using Com As New SqlCommand("Select * From tablename", Con)
    Using RDR = Com.ExecuteReader()
        If RDR.HasRows Then
            Do While RDR.Read
                txtName.Text =txtName.Text & RDR.Item("Name").ToString() & VBCLRF
            Loop
        End If
    End Using
End Using
Con.Close()
End Using