Hello
Only one time count the msg ok result. but after that when I type wrong username and password coding not work. please help me .........
Try
Dim erorcunt As Integer
erorcunt = 0
Dim myConnection As OleDbConnection
myConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\DB.accdb;Persist Security Info=False;")
Dim myCommand As OleDbCommand
myCommand = New OleDbCommand("SELECT uid,pswrd FROM Users WHERE uid = @username AND pswrd = @UserPassword", myConnection)
Dim uName As New OleDbParameter("@username", SqlDbType.VarChar)
Dim uPassword As New OleDbParameter("@UserPassword", SqlDbType.VarChar)
uName.Value = Username.Text
uPassword.Value = Password.Text
myCommand.Parameters.Add(uName)
myCommand.Parameters.Add(uPassword)
myCommand.Connection.Open()
Dim myReader As OleDbDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
Dim Login As Object = 0
If myReader.HasRows Then
myReader.Read()
Login = myReader(Login)
End If
If Login = Nothing Then
Dim msgrlt As MsgBoxResult = MessageBox.Show("Login is Failed...Try again !", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
If msgrlt = MsgBoxResult.Ok Then
erorcunt = erorcunt + 1
End If
Username.Clear()
Password.Clear()
Username.Focus()
Label3.Text = erorcunt
If erorcunt = 3 Then
Application.Exit()
End If
Else
ProgressBar1.Visible = True
ProgressBar1.Maximum = 5000
ProgressBar1.Minimum = 0
ProgressBar1.Value = 4
ProgressBar1.Step = 1
Me.Hide()
For i = 0 To 5000
ProgressBar1.PerformStep()
Next
frmmain.ToolStripStatusLabel2.Text = Username.Text
Me.Hide()
frmmain.Show()
Me.BackColor = Color.Red
End If
myCommand.Dispose()
myConnection.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try