我尝试用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
1条答案
按热度按时间vlju58qv1#
可以这样尝试(基于datareader msdn文章):