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
 

levyuk

Well-known member
Joined
Jun 7, 2004
Messages
313
Location
Wales, UK
Programming Experience
3-5
why do you have the .trim part of the text?
VB.NET:
DBConnection(txtUserName.Text.Trim(), txtPassword.Text.Trim())
 

kulrom

Well-known member
Joined
May 10, 2005
Messages
2,854
Location
Republic of Macedonia
Programming Experience
10+
Probably he wants to avoid user's typo and remove/trim white spaces from there ... but i don't think so it's the problem he has at the moment ... hmm let me check this for a while and i'll back with a suggestion
Kind regards ;)
 

David_nyh

Member
Joined
Mar 4, 2005
Messages
16
Programming Experience
Beginner
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
 

kulrom

Well-known member
Joined
May 10, 2005
Messages
2,854
Location
Republic of Macedonia
Programming Experience
10+
pretty easy ... but i can't help you today ... today is my birthday, i hope you don't mind ... btw, sorry cuz i spent this post for almost nothing ... but anyway i told him that it's pretty easy and he shouldn't worry about ...
Kind regards :)
 

David_nyh

Member
Joined
Mar 4, 2005
Messages
16
Programming Experience
Beginner
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.
 

kulrom

Well-known member
Joined
May 10, 2005
Messages
2,854
Location
Republic of Macedonia
Programming Experience
10+
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 :)
 
Top Bottom