Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Try
connection.Open()
If Me.PasswordTextBox.Text.Length < 6 Then
MsgBox("Password too short", MsgBoxStyle.Critical, "Error")
Me.PasswordTextBox.SelectAll()
Me.PasswordTextBox.Focus()
Exit Sub
End If
Dim cmd As New SqlCommand("Select * From Account where Password='" & Me.PasswordTextBox.Text & "' and UserName= '" & Me.UsernameTextBox.Text & "'", connection)
Dim ReadLogin As SqlDataReader = cmd.ExecuteReader
If ReadLogin.HasRows Then
Me.Hide()
Dim Main As New MainForm
Main.Show()
Else
MsgBox("Error logging in to the sytem.Please check username and password", MsgBoxStyle.Critical, "Cannot login")
connection.Close()
cmd.Dispose()
ReadLogin.Close()
End If
catch ex As Exception
MessageBox.Show("An Error Occured,Restart Application and Login Again", "Restart Application")
Me.Close()
End Try
End Sub
This post has been edited by AdamSpeight2008: 10 June 2010 - 10:04 AM
Reason for edit:: Corrected Code Tags

New Topic/Question
Reply




MultiQuote




|