`Public Class login
Dim cnn As New OleDb.OleDbConnection
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Dim cmd As New OleDb.OleDbCommand
If Not cnn.State = ConnectionState.Open Then
cnn.Open()
End If
cmd.Connection = cnn
If cmd.CommandText = "SELECT UName FROM Account WHERE UName =" & Me.UsernameTextBox.Text Then
If cmd.CommandText = "SELECT PWord FROM Account WHERE PWord =" & Me.PasswordTextBox.Text Then
Dim f As Form = Application.OpenForms.Item("Main")
If f Is Nothing Then
Dim MainForm As New Main
Main.Show()
Else
f.BringToFront()
End If
Me.Hide()
Else
MsgBox("Invalid password.Please try again!", MsgBoxStyle.Exclamation)
PasswordTextBox.Focus()
End If
Else
MsgBox("Invalid Username.Please try again!", MsgBoxStyle.Exclamation)
UsernameTextBox.Focus()
End If
cmd.ExecuteNonQuery()
cnn.Close()
End Sub
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
Me.Close()
End Sub
Private Sub login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cnn = New OleDb.OleDbConnection
cnn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Database.accdb"
End Sub
End Class`
above is my code.can someone tell me where is wrong?