我有一些代码要从 mysql 数据库中读取,但我只是想知道如何修改它以查看表中是否存在用户?
谢谢
Private Sub GetDBData()
Try
'prepare connection query
strQuery = "SELECT users.Username, users.Password " & _
"FROM users " & _
"WHERE Username='User'"
SQLCmd = New MySqlCommand(strQuery, dbCon)
'open db and start query
dbCon.Open()
DR = SQLCmd.ExecuteReader
While DR.Read
MysqlData.Text = MysqlData.Text & DR.Item("Username") & Space(10) & DR.Item("Password") & vbCrLf
End While
'done so closing db
DR.Close()
dbCon.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub