Please note - I'm not an ASP developer, I'm a VB/VBA developer - as a result, this has not been tested at all. However, I hope it should give you the general principles of what is needed:
ASP code for your web page
Code:
Dim oConnection ' ADODB.Connection object to connect to database
Dim oRS ' ADODB.Recordset to host results of data query
Dim sQuery ' String data for SQL query
' Connect to a Microsoft Access Database from ASP using DSN-less OLEDB connection
Set oConnection = Server.CreateObject("ADODB.Connection")
oConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
Server.MapPath("d:\data\yourdb.mdb") & ";UID=Admin;PWD="
sQuery = "qryValidateUser" ' name of query from Access front end
' Add parameters to the query as comma separated items
sQuery = sQuery & "'" & Username & "','" & Password & "'"
Set oRS = Server.CreateObject("ADODB.Recordset")
oRS.Open sQuery, oConnection
' now validate the query
If oRS!Total > 0 Then
' Correct password
Else
' Incorrect Password
End If
' Close the connection
oConnection.Close
Set oConnection = Nothing
Create the query qryValidateUser with the following SQL code:
Code:
SELECT count (*) As Total
FROM Users
WHERE UserID = [EnterUserID] And Password = [EnterPassword]
When you run this query manually through Access, and enter a valid user id/password combination, you get a 1, if not, you get 0. That is your overall status
This way:
1. You aren't retrieving the password as a valid from the db - its just retrieving 0 if there is no valid username/password combination, or 1 if there is.
2. If you encrypt the passwords, then the entered password needs to be scrambled in the same way before validating.
3. Access query strings can be found from
if you need help to customise it to your own needs.
4. Using Server.MapPath means you can store the data outside the web root, which is good for security (ie your users can't go to
and download the entire list of users and passwords.
I'd be interested to hear how you get on.
John