获取MySQL表的所有行并将它们放入列表框中

时间:2017-06-30 20:39:54

标签: mysql database vb.net

我想获取MySQL数据库的所有表行并将它们存储在列表框中。我正在使用vb.net。提前谢谢。

1 个答案:

答案 0 :(得分:0)

    Dim connection As New SqlConnection
    Dim cmd As New SqlCommand
    Dim dr As SqlDataReader
    Dim Column0 As String

    connection.ConnectionString = "Data Source=localhost; Initial Catalog=catalogname; Integrated Security=True; Connection Timeout=3"

    Dim query As String = "SELECT * FROM MyDB"

    connection.Open()

    cmd = New SqlCommand(query, connection)
    dr = cmd.ExecuteReader

    If dr.Read() Then
    Column0 = dr(0)
    End If

    connection.Close()