Ok guys I have been working on this for hours and I still cant figure out what the problem is. So here is my setup
web.config
Each user has a unique "lid_id" so my access procedure looks like this in ms access query (sp_ValidateUser).
and the table "tabel_leden" has 6 columns (lid_id, lid_naam, lid_password, lid_achternaam, lid_adres and lid_email)
login.aspx Database connection
login.aspx submit button
In my database I have an user named Maes and his password is lollol.
When I fill these in I get the error text "Invalid Login! test-2"
Thanks
David
web.config
VB.NET:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!-- APPLICATION SETTINGS -->
<appSettings>
<add key="strConn" value="Provider = Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\bibliotheek\database\bib.mdb;User ID=Admin;Password=;"/>
</appSettings>
<system.web>
...
Each user has a unique "lid_id" so my access procedure looks like this in ms access query (sp_ValidateUser).
VB.NET:
SELECT tabel_leden.lid_id
FROM tabel_leden
WHERE (((tabel_leden.lid_naam)=[@LidNaam] AND ((tabel_leden.lid_password)=[@LidPassword]));
and the table "tabel_leden" has 6 columns (lid_id, lid_naam, lid_password, lid_achternaam, lid_adres and lid_email)
login.aspx Database connection
VB.NET:
Function DBConnection(ByVal strUserName As String, ByVal strPassword As String) As Boolean
Dim MyConn As OleDbConnection = New OleDbConnection(ConfigurationSettings.AppSettings("strConn"))
Dim MyCmd As New OleDbCommand("sp_ValidateUser", MyConn)
MyCmd.CommandType = CommandType.StoredProcedure
Dim objParam1, objParam2 As OleDbParameter
objParam1 = MyCmd.Parameters.Add("@LidNaam", OleDbType.Char)
objParam2 = MyCmd.Parameters.Add("@LidPassword", OleDbType.Char)
objParam1.Direction = ParameterDirection.Input
objParam2.Direction = ParameterDirection.Input
objParam1.Value = strUserName
objParam2.Value = strPassword
Try
If MyConn.State = ConnectionState.Closed Then
MyConn.Open()
End If
Dim objReader As OleDbDataReader
objReader = MyCmd.ExecuteReader(CommandBehavior.CloseConnection)
While objReader.Read()
If CStr(objReader.GetValue(0)) <> "1" Then
lblMessage.Text = "Invalid Login! test-1"
Else
objReader.Close()
Return True
End If
End While
Catch ex As Exception
lblMessage.Text = "Error Connecting to Database!"
End Try
End Function
login.aspx submit button
VB.NET:
Private Sub cmdSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSubmit.Click
If Page.IsValid Then
If DBConnection(txtUserName.Text.Trim(), txtPassword.Text.Trim()) Then
Session("Logged_IN") = "Yes"
FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, False)
Else
lblMessage.Text = "Invalid Login! test-2"
End If
End If
End Sub
In my database I have an user named Maes and his password is lollol.
When I fill these in I get the error text "Invalid Login! test-2"
Thanks
David