我刚刚在VB.NET中学习过MySQL,但我有一个复杂的问题......
当我抓住SELECT查询时,我想得到 - 让我们说它收到的每一行中的'用户名'列。我该怎么做?
MySQL.CommandText = "SELECT * FROM online"
MySQL.ExecuteNonQuery()
Label1.Text = 'usernamehere'
谢谢:)
答案 0 :(得分:1)
Public Sub CreateMySqlDataReader(mySelectQuery As String, myConnection As MySqlConnection)
Dim myCommand As New MySqlCommand(mySelectQuery, myConnection)
myConnection.Open()
Dim myReader As MySqlDataReader
myReader = myCommand.ExecuteReader()
Try
While myReader.Read()
Console.WriteLine(myReader.GetString(0))
End While
Finally
myReader.Close
myConnection.Close
End Try
End Sub
也作为奖励。如果您要在该查询中输入一些参数,我建议您查看预处理语句。