0
我試圖用mysql在登錄系統上創建。但我不知道它不起作用。它每次都會再次嘗試什麼問題?vb.net無法連接到mysql
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
mysqlconn = New MySqlConnection
mysqlconn.ConnectionString = "server=localhost;userid=root;password=;database=tes"
Dim reader As MySqlDataReader
Try
mysqlconn.Open()
Dim query As String = "select * from kullanicilar where 'username=" & TextBox1.Text & "' and 'password=" & TextBox2.Text & "'"
komut = New MySqlCommand(query, mysqlconn)
reader = komut.ExecuteReader
Dim girdimi As Integer = 0
If reader.Read Then
girdimi = girdimi + 1
End If
If girdimi = 1 Then
Form2.Show()
ElseIf girdimi = 0 Then
MessageBox.Show("try again")
End If
mysqlconn.Close()
Catch ex As MySqlException
MessageBox.Show(ex.Message)
Finally
mysqlconn.Dispose()
End Try
End Sub
SELECT * FROM kullanicilar其中 '用戶名=富' 和 '密碼=欄' 應該是SELECT * FROM kullanicilar其中username =」 foo'和密碼='bar' – Paul
MessageBox.Show(查詢) – Paul
哦,謝謝,它的工作原理 – MuhammedM2