将来自MySql查询的值放入vb中的表单中

时间:2016-03-30 13:23:42

标签: mysql vb.net

我正在尝试从MySql表中提取值并将它们放在VB中的表单上。我希望用户列出他/她目前租用的所有电影。我知道MySql语句有效,所以它只是实际获取值的问题。任何帮助都会很棒!我有以下代码:

 Private Sub Form9_Load(sender As Object, e As EventArgs) Handles     MyBase.Load
    NoMovies.Visible = False
    Dim query As String
    Dim ans As String
    Dim ds As New DataSet
    Dim da As New MySqlDataAdapter
    MysqlConn = New MySqlConnection
    Dim Reader As MySqlDataReader
    'another query and a two table join'
    query = "SELECT movie_name from movie2 Where movie_id=(SELECT movie_id from rental where client_username='" & currentUser & "' AND start_date<='" & DateTime.Now.ToString("yyyy-MM-dd") & "' AND return_date>='" & DateTime.Now.ToString("yyyy-MM-dd") & "')"
    MysqlConn.ConnectionString =
          "server=mysql.scss.tcd.ie;userid=murpha83;password=gh8ht6789;database=murpha83_db"
    MysqlConn.Open()
    Command = New MySqlCommand(query, MysqlConn)
    da = New MySqlDataAdapter(Command)
    da.Fill(ds, "Subject_Detail")
    Reader = Command.ExecuteReader
    If Reader.HasRows = True Then
    'Think I Should extract the values and put them on the form here '


    Else
        NoMovies.Visible = True
    End If
    MysqlConn.Close()
    Reader.Close()
End Sub

谢谢, 艾伦。

0 个答案:

没有答案