jamesbon007
New member
- Joined
- Mar 6, 2008
- Messages
- 1
- Programming Experience
- Beginner
Hi everyone,
I've managed to write some code which allows me to login into my application. However i would like to notify the user if he or she enters the wrong username or the wrong password? Am not sure how to go about this.
This is what i got so far
I've managed to write some code which allows me to login into my application. However i would like to notify the user if he or she enters the wrong username or the wrong password? Am not sure how to go about this.
This is what i got so far
VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conn As New OleDb.OleDbConnection("Provider=sqloledb;Data Source=GSTT-CVC-R1;Initial Catalog=TestDp;User Id=Test;Password=testpass;")
Dim sql As String
FileSystem.FileOpen(2, "C:\temp\test.txt", OpenMode.Append, OpenAccess.ReadWrite, OpenShare.Shared)
Dim userlogin, userpassword As String
userlogin = txtLogin.Text
userpassword = txtPassword.Text
sql = "SELECT * from tbl_users where LoginName = '" & userlogin & "' AND LoginPassword = '" & userpassword & "'"
Dim mycmdReader As New OleDb.OleDbCommand(sql, conn)
Dim LoginReader As System.Data.OleDb.OleDbDataReader
Try
conn.Open()
LoginReader = mycmdReader.ExecuteReader
FileSystem.PrintLine(2, "Open connection" & "***" & Now())
Catch ex As Exception
MsgBox(Err.Description)
FileSystem.PrintLine(2, "Error: " & Err.Description & "***" & Now())
Exit Sub
End Try
If LoginReader.HasRows Then
LoginReader.Read()
FileSystem.PrintLine(2, "LOGGED IN: " & userlogin & "***" & Now())
Else
FileSystem.PrintLine(2, "LOGIN FAILED" & "***" & Now())
End If
FileSystem.FileClose(2)
End Sub