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("username"
varPassword=Request.Form("password"
varPass = 0
Set oRS=Server.CreateObject("ADODB.recordset"
sqlText = "SELECT * FROM users ORDER BY username;"
oRS.open sqlText, "DSN=isdb"
oRS.MoveFirst
Do while NOT oRS.EOF
If varUserID <> "" and varPassword <> "" and varUserID = oRS("username"
and varPassword = oRS("password"
then
varPass = 1
varLevel = oRS("level"
End if
oRS.MoveNext
Loop
If varPass = 0 then
Response.write "<p> </p><center><b>Access denied.</b></center>"
Else
oRS.close
Set oRS=Server.CreateObject("ADODB.recordset"
sqlText = "SELECT * FROM service ORDER BY serviceid;"
oRS.open sqlText, "DSN=isdb"
oRS.MoveFirst
Response.write "<table width=90% align=center border=1 cellspacing=0 cellpadding=3><tr bgcolor=2A344F>"
Response.write "<th><font color=9AA2B5>Service<th><font color=9AA2B5>UserID"
Response.write "<th><font color=9AA2B5>Password<th><font color=9AA2B5>Location</tr>"
Do while NOT oRS.EOF
If varLevel >= oRS("level"
then
If rowColor = "#62718F" then
rowColor = "#39445B"
Else
rowColor = "#62718F"
End if
Response.write "<tr valign=top bgcolor=" & rowColor & ">"
Response.write "<td>" & oRS("service"
& "</td>"
Response.write "<td>" & oRS("username"
& "</td>"
Response.write "<td>" & oRS("password"
& "</td>"
Response.write "<td>" & oRS("servicelocation"
& "</td></tr>"
End if
oRS.MoveNext
Loop
Response.write "</table>"
oRS.close
%>
<p> </p>
<p> </p>
<p align="center"> <b>Alarm Codes</b></p>
<%
Set oRS=Server.CreateObject("ADODB.recordset"
sqlText = "SELECT * FROM alarm ORDER BY alarmid;"
oRS.open sqlText, "DSN=isdb"
oRS.MoveFirst
Response.write "<table width=90% align=center border=1 cellspacing=0 cellpadding=3><tr bgcolor=2A344F>"
Response.write "<th><font color=9AA2B5>Location<th><font color=9AA2B5>Description"
Response.write "<th><font color=9AA2B5>Disarm Code<th><font color=9AA2B5>Arm Code</tr>"
Do while NOT oRS.EOF
If varLevel >= oRS("level"
then
If rowColor = "#62718F" then
rowColor = "#39445B"
Else
rowColor = "#62718F"
End if
Response.write "<tr valign=top bgcolor=" & rowColor & ">"
Response.write "<td>" & oRS("location"
& "</td>"
Response.write "<td>" & oRS("description"
& "</td>"
Response.write "<td>" & oRS("disarmcode"
& "</td>"
Response.write "<td>" & oRS("armcode"
& "</td></tr>"
End if
oRS.MoveNext
Loop
Response.write "</table>"
End if
oRS.close
set oRS=nothing
%>
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("username"
varPassword=Request.Form("password"
varPass = 0
Set oRS=Server.CreateObject("ADODB.recordset"
sqlText = "SELECT * FROM users ORDER BY username;"
oRS.open sqlText, "DSN=isdb"
oRS.MoveFirst
Do while NOT oRS.EOF
If varUserID <> "" and varPassword <> "" and varUserID = oRS("username"
varPass = 1
varLevel = oRS("level"
End if
oRS.MoveNext
Loop
If varPass = 0 then
Response.write "<p> </p><center><b>Access denied.</b></center>"
Else
oRS.close
Set oRS=Server.CreateObject("ADODB.recordset"
sqlText = "SELECT * FROM service ORDER BY serviceid;"
oRS.open sqlText, "DSN=isdb"
oRS.MoveFirst
Response.write "<table width=90% align=center border=1 cellspacing=0 cellpadding=3><tr bgcolor=2A344F>"
Response.write "<th><font color=9AA2B5>Service<th><font color=9AA2B5>UserID"
Response.write "<th><font color=9AA2B5>Password<th><font color=9AA2B5>Location</tr>"
Do while NOT oRS.EOF
If varLevel >= oRS("level"
If rowColor = "#62718F" then
rowColor = "#39445B"
Else
rowColor = "#62718F"
End if
Response.write "<tr valign=top bgcolor=" & rowColor & ">"
Response.write "<td>" & oRS("service"
Response.write "<td>" & oRS("username"
Response.write "<td>" & oRS("password"
Response.write "<td>" & oRS("servicelocation"
End if
oRS.MoveNext
Loop
Response.write "</table>"
oRS.close
%>
<p> </p>
<p> </p>
<p align="center"> <b>Alarm Codes</b></p>
<%
Set oRS=Server.CreateObject("ADODB.recordset"
sqlText = "SELECT * FROM alarm ORDER BY alarmid;"
oRS.open sqlText, "DSN=isdb"
oRS.MoveFirst
Response.write "<table width=90% align=center border=1 cellspacing=0 cellpadding=3><tr bgcolor=2A344F>"
Response.write "<th><font color=9AA2B5>Location<th><font color=9AA2B5>Description"
Response.write "<th><font color=9AA2B5>Disarm Code<th><font color=9AA2B5>Arm Code</tr>"
Do while NOT oRS.EOF
If varLevel >= oRS("level"
If rowColor = "#62718F" then
rowColor = "#39445B"
Else
rowColor = "#62718F"
End if
Response.write "<tr valign=top bgcolor=" & rowColor & ">"
Response.write "<td>" & oRS("location"
Response.write "<td>" & oRS("description"
Response.write "<td>" & oRS("disarmcode"
Response.write "<td>" & oRS("armcode"
End if
oRS.MoveNext
Loop
Response.write "</table>"
End if
oRS.close
set oRS=nothing
%>