0

Imports System.Data.OleDb
Public Class LoginForm1

Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
    Try
            Dim con As New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=C:\Users\Documents\VodStore\VodStore\bin\Debug\VodStock.mdb")
        Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM Users WHERE userid = '" & UsernameTextBox.Text & "' AND password = '" & PasswordTextBox.Text & "' ", con)
        cmd.Connection.Open()
        'con.Open()
        Dim sdr As OleDbDataReader = cmd.ExecuteReader()
        ' If the record can be queried, Pass verification and open another form.   
        If (sdr.Read() = True) Then
            MessageBox.Show("Access Granted!")
            Form1.Show()
            Me.Hide()
        Else
            MessageBox.Show("Access Denied! Invalid username or password.")
        End If
    Catch es As Exception
        Beep()
        MsgBox(es.Message)
    End Try
End Sub

Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
    Me.Close()
End Sub

End Class

Here i got the problem of "Data type mismatch in criteria expression.". Please help me...

2
Contributors
1
Reply
9
Views
3 Years
Discussion Span
Last Post by gusano79
0

To answer your question, we need to know:

  1. What is the table definition for Users?
  2. What values are in UserNameTextBox.Text and PasswordTextBox.Text?

It would also help (you just as much as us) to look at the final SQL query string in cmd.CommandText.

Edited by gusano79: added information

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.