列在Vb.net Sqldatareader中

时间:2016-12-20 06:26:40

标签: vb.net sqldatareader

是否可以将列表应用于此代码?在提供文本框和datareader项目方面。

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 个答案:

答案 0 :(得分:-1)

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