formlesstree4
Well-known member
- Joined
- Jul 17, 2008
- Messages
- 61
- Programming Experience
- 1-3
Well, I've been trying for about 3 weeks now (sad, I know) to get a login form read from a database. I've tried a lot of things, and so far, nothing works. This is what I have so far:
My problem is, I don't know if it connects or even checks. Cause this is the error I get:
Any help would be nice.
VB.NET:
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Dim dr As SqlCeDataReader = cmd.ExecuteReader
cmd = New SqlCeCommand("SELECT Username,Password FROM users WHERE Username ='" & txtUser.Text & "' AND Password ='" & getMD5Hash(txtPassword.Text) & "')", con)
con.Open()
cmd.ExecuteNonQuery()
Try
Catch ex As InvalidOperationException
MsgBox(ex.Message)
End Try
Try
If dr.Read = False Then
MessageBox.Show("Authentication Failed...")
Else
MessageBox.Show("Login Successful...")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
If con.State <> ConnectionState.Closed Then
con.Close()
End If
End Sub
My problem is, I don't know if it connects or even checks. Cause this is the error I get:
VB.NET:
"Object reference not set to an instance of an object."
Any help would be nice.