这是我的代码,我收到错误消息"未知表'用户'在字段列表" 我该如何解决这个问题?
Imports MySql.Data
Imports MySql.Data.MySqlClient
Public Class Form1
Dim mysqlconn As New MySqlConnection
Dim command As MySqlCommand
Dim query As String = ""
Dim reader As MySqlDataReader
Private Sub loginbutton_Click(sender As Object, e As EventArgs) Handles loginbutton.Click
getdbdata()
End Sub
Private Sub getdbdata()
Try
mysqlconn = New MySqlConnection("server=localhost;username=root;database=bank")
query = "select user.Username, user.Password, user.Email" & _
"from user"
command = New MySqlCommand(query, mysqlconn)
mysqlconn.Open()
reader = command.ExecuteReader
While reader.Read
txtusername.Text = txtusername.Text & reader.Item("Username") & vbCrLf
txtpassword.Text = txtpassword.Text & reader.Item("Password") & vbCrLf
txtemail.Text = txtemail.Text & reader.Item("Email")
End While
reader.Close()
mysqlconn.Close()
Catch ex As MySqlException
MessageBox.Show(ex.Message)
End Try
End Sub
答案 0 :(得分:0)
“银行”数据库中的表是“用户”吗?如果是这样,试试这个:
query = "select Username, Password, Email " & _
"from [user]"