I have to make a User-and-Password system to a program as apart of my final project for college.
It has to use a database and rely on the database entirely.
I got the login system working, but I wanted to go the extra distance and add in a login failure system.
It works by adding a new row into a table called tblErrors.
Every time a user fails to login correctly, it adds a new entry.
There's 4 parts. Error type, time and date it occurred and a note about the error.
The error system will expand as I go on, so I tried to keep the system as bland as possible.
Anyway, here's the segment of code I'm using for the login system:
As you can see, it's clearly using Now ShortTime. It returns as normal time, but in the database it looks like this:
Any help? I think it could be an error with the .Update() system. I tried forcing 12:00 as a test, but it STILL puts it in as the date (2009-10-16).
It has to use a database and rely on the database entirely.
I got the login system working, but I wanted to go the extra distance and add in a login failure system.
It works by adding a new row into a table called tblErrors.
Every time a user fails to login correctly, it adds a new entry.
There's 4 parts. Error type, time and date it occurred and a note about the error.
The error system will expand as I go on, so I tried to keep the system as bland as possible.
Anyway, here's the segment of code I'm using for the login system:
VB.NET:
If DsUsers1.tblUsers.Rows.Contains(txtUser.Text()) Then
PWtest = DsUsers1.tblUsers.Rows.Find(txtUser.Text())
If txtUser.Text() = PWtest("flPassword") Then
Me.Hide()
login.ShowDialog()
Else
MsgBox("Login failed. Attempt logged.", MsgBoxStyle.Critical, "Login Error")
Dim NewError As System.Data.DataRow
NewError = DsErrors1.tblErrors.NewRow
NewError.Item("flType") = "Login Error"
NewError.Item("flTime") = FormatDateTime(Now, DateFormat.ShortTime)
NewError.Item("flDate") = FormatDateTime(Now, DateFormat.ShortDate)
NewError.Item("flNote") = "User: " + txtUser.Text() + " " + "Password: " + txtPassword.Text()
DsErrors1.tblErrors.Rows.Add(NewError)
daErrors.Update(DsErrors1)
daErrors.Fill(DsErrors1)
txtUser.Clear()
txtPassword.Clear()
End If
Else
MsgBox("Login failed. Attempt logged.", MsgBoxStyle.Critical, "Login Error")
Dim NewError As System.Data.DataRow
NewError = DsErrors1.tblErrors.NewRow
NewError.Item("flType") = "Login Error"
NewError.Item("flTime") = FormatDateTime(Now, DateFormat.ShortTime)
NewError.Item("flDate") = FormatDateTime(Now, DateFormat.ShortDate)
NewError.Item("flNote") = "User: " + txtUser.Text() + " " + "Password: " + txtPassword.Text()
DsErrors1.tblErrors.Rows.Add(NewError)
daErrors.Update(DsErrors1)
daErrors.Fill(DsErrors1)
txtUser.Clear()
txtPassword.Clear()
End If
As you can see, it's clearly using Now ShortTime. It returns as normal time, but in the database it looks like this:
VB.NET:
flErrorID flType flTime flDate flNote
30 Login Error 2009-10-16 2009-10-16 User: User1 Password: Test
31 Login Error 2009-10-16 2009-10-16 User: Password:
Any help? I think it could be an error with the .Update() system. I tried forcing 12:00 as a test, but it STILL puts it in as the date (2009-10-16).