Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connecting to a Password Protected Access Database?

Status
Not open for further replies.

tjacoby

IS-IT--Management
Mar 21, 2002
6
0
0
US
Hello Everyone,

My question is how do I connect to an Access Database that has a password on it, using the connection type below?

Set oRS=Server.CreateObject("ADODB.recordset")
sqlText = "SELECT * FROM users ORDER BY username;"
oRS.open sqlText, "DSN=isdb"

At first I thought I just setup the System DSN to use a user name and password, but that does not work. The password on the Access Database file is one use to stop people from going into the computer room, hoping on to the system, and reading the information in the Access Database. So it is not a user/password of the Access Database. Does that make any sense?

I guess what I need to know, is what do I need to change in my scripting to make the connection to the password protected database work... :)

Here is the full code being used(users.asp):


<%
Dim varUserID
Dim varPassword
Dim varLevel
Dim varPass
Dim rowColor
Dim sqlText
Dim oRS

varUserID=Request.Form(&quot;username&quot;)
varPassword=Request.Form(&quot;password&quot;)
varPass = 0

Set oRS=Server.CreateObject(&quot;ADODB.recordset&quot;)
sqlText = &quot;SELECT * FROM users ORDER BY username;&quot;
oRS.open sqlText, &quot;DSN=isdb&quot;

oRS.MoveFirst
Do while NOT oRS.EOF
If varUserID <> &quot;&quot; and varPassword <> &quot;&quot; and varUserID = oRS(&quot;username&quot;) and varPassword = oRS(&quot;password&quot;) then
varPass = 1
varLevel = oRS(&quot;level&quot;)
End if
oRS.MoveNext
Loop

If varPass = 0 then
Response.write &quot;<p> </p><center><b>Access denied.</b></center>&quot;
Else
oRS.close

Set oRS=Server.CreateObject(&quot;ADODB.recordset&quot;)
sqlText = &quot;SELECT * FROM service ORDER BY serviceid;&quot;
oRS.open sqlText, &quot;DSN=isdb&quot;

oRS.MoveFirst
Response.write &quot;<table width=90% align=center border=1 cellspacing=0 cellpadding=3><tr bgcolor=2A344F>&quot;
Response.write &quot;<th><font color=9AA2B5>Service<th><font color=9AA2B5>UserID&quot;
Response.write &quot;<th><font color=9AA2B5>Password<th><font color=9AA2B5>Location</tr>&quot;
Do while NOT oRS.EOF
If varLevel >= oRS(&quot;level&quot;) then
If rowColor = &quot;#62718F&quot; then
rowColor = &quot;#39445B&quot;
Else
rowColor = &quot;#62718F&quot;
End if
Response.write &quot;<tr valign=top bgcolor=&quot; & rowColor & &quot;>&quot;
Response.write &quot;<td>&quot; & oRS(&quot;service&quot;) & &quot;</td>&quot;
Response.write &quot;<td>&quot; & oRS(&quot;username&quot;) & &quot;</td>&quot;
Response.write &quot;<td>&quot; & oRS(&quot;password&quot;) & &quot;</td>&quot;
Response.write &quot;<td>&quot; & oRS(&quot;servicelocation&quot;) & &quot;</td></tr>&quot;
End if
oRS.MoveNext
Loop
Response.write &quot;</table>&quot;
oRS.close

%>
<p> </p>
<p> </p>
<p align=&quot;center&quot;> <b>Alarm Codes</b></p>

<%
Set oRS=Server.CreateObject(&quot;ADODB.recordset&quot;)
sqlText = &quot;SELECT * FROM alarm ORDER BY alarmid;&quot;
oRS.open sqlText, &quot;DSN=isdb&quot;

oRS.MoveFirst
Response.write &quot;<table width=90% align=center border=1 cellspacing=0 cellpadding=3><tr bgcolor=2A344F>&quot;
Response.write &quot;<th><font color=9AA2B5>Location<th><font color=9AA2B5>Description&quot;
Response.write &quot;<th><font color=9AA2B5>Disarm Code<th><font color=9AA2B5>Arm Code</tr>&quot;
Do while NOT oRS.EOF
If varLevel >= oRS(&quot;level&quot;) then
If rowColor = &quot;#62718F&quot; then
rowColor = &quot;#39445B&quot;
Else
rowColor = &quot;#62718F&quot;
End if
Response.write &quot;<tr valign=top bgcolor=&quot; & rowColor & &quot;>&quot;
Response.write &quot;<td>&quot; & oRS(&quot;location&quot;) & &quot;</td>&quot;
Response.write &quot;<td>&quot; & oRS(&quot;description&quot;) & &quot;</td>&quot;
Response.write &quot;<td>&quot; & oRS(&quot;disarmcode&quot;) & &quot;</td>&quot;
Response.write &quot;<td>&quot; & oRS(&quot;armcode&quot;) & &quot;</td></tr>&quot;
End if
oRS.MoveNext
Loop
Response.write &quot;</table>&quot;
End if

oRS.close
set oRS=nothing

%>
 
You must specify this information in your connection, not the opening of your recordset. Try this connection string:

dim strCon,con
set con = server.createObject(&quot;ADODB.Connection&quot;)
strCon = &quot;Provider=Microsoft.Jet.OLEDB.4.0;Password=2987;Data Source=Q:\inetpub\ Security Info=True;UID=helpme;PWD=imstupid&quot;
con.open strCon

Of course, you'll have to replace the actual location of your database **cough** with a true string that will find the db, and the authentication info with the required stuff.

[lightsaber]
 
ijustwannahelp,

Thanks for the information, I will give that a try, and yes I am a newbie in need of help :)

Travis
 
ok, figured this out...

I had to create an user account in the DB, then setup the DSN using that user name and password, from there you can then put a password on the DB file.

Thanks for those of you gave input...

And yes, I am a Newbie in some serious need of umm help? :)

Travis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top