您好我新來的Visual Studio,我總是得到這個錯誤「您的SQL語法錯誤;檢查手冊,對應您的SQL」您的SQL語法錯誤;檢查與您的SQL相對應的手冊
這是我的代碼,你
Public Class Form1
Dim MysqlConn As MySql.Data.MySqlClient.MySqlConnection
Dim UsersCommand As New MySql.Data.MySqlClient.MySqlCommand
Dim UsersAdapter As New MySql.Data.MySqlClient.MySqlDataAdapter
Dim UsersData As New DataTable
Dim SQL As String
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MysqlConn = New MySql.Data.MySqlClient.MySqlConnection()
' Define the SQL to prob data from table.
SQL = "Select FROM wala"
'Connection String
MysqlConn.ConnectionString = "server=localhost;" & "user id=Taena;" & "password=Taena;" & "database=wala"
Try
MysqlConn.Open()
UsersCommand.Connection = MysqlConn
UsersCommand.CommandText = SQL
UsersAdapter.SelectCommand = UsersCommand
UsersAdapter.Fill(UsersData)
DataGridView1.DataSource = UsersData
Catch myerror As MySql.Data.MySqlClient.MySqlException
MessageBox.Show("Cannot connect to database1" & myerror.Message)
Finally
MysqlConn.Close()
MysqlConn.Dispose()
End Try
End Sub
End Class