帮助我使用vb.net2010并尝试通过sqlyog访问我的数据库但是con.Open()行似乎有错误。(我正在尝试使用数据库创建一个登录表单,这是我的第一次)
Public con As New Odbc.OdbcConnection
Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click
con = New Odbc.OdbcConnection("dsn=cara")
Dim cmd As New Odbc.OdbcCommand
Dim reader As Odbc.OdbcDataReader
cmd.Connection = con
con.Open()
cmd.CommandText = " SELECT username,password FROM userinfo WHERE username='" & txtusername.Text & "' and password='" & txtpassword.Text & "'"
reader = cmd.ExecuteReader
If reader.HasRows Then
Admin_Page.Show()
Else
MessageBox.Show("Invalid Username or Password")
End If