Doesn't accept password

David_nyh

Member
Joined
Mar 4, 2005
Messages
16
Programming Experience
Beginner
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
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
 
I solved the problem by coding it different.

But now now I'm searching for tutorials are examples how you can add roles like users and admin access. Where the roles and the names of the users and admins with their password stored in microsoft access database.

I found some but they don't you ms-access.

David
 
Sorry but I need it for asp.net using vb and ms-access where I store the the names and passwords from the users and admins.
 
take a look the forum title ... asp.net is in another section ... but anyway the logic is almost same ... :)

I'm so sorry but i have no time to recode all that in asp.net ... i hope you don't mind ... maybe tomorow or day after tomorow ... today i'm going to hang with my friends out ... hahaha

Kind regards :)
 
Back
Top