未找到数据源名称且没有默认驱动程序说明

时间:2016-09-17 15:12:43

标签: vb.net sqlyog

帮助我使用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

0 个答案:

没有答案