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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Security/Data Access?

Status
Not open for further replies.

jasonp45

Programmer
Aug 23, 2001
212
US
I created an ASP page that pulls a recordset from an Access database and displays the recordset in a table. Simple enough.

I designed the table in FrontPage and displayed the results on my own machine - I guess using the internal Win2K Web server (IIS? Web Publishing Service?). Everything worked as I anticipated.

However, once I moved the ASP page over to the *real* web server, it generated an error, saying the database it was pointed toward was either locked by an exclusive user or unavailable.

I specified the UNC name in my code, and all machines are on the same intranet in the same Win2K domain. Data sharing like this works fine in VB/Script, so I assume this is some sort of ASP security issue. Or possibly it's some of the code that FrontPage generated. Can someone please tell me what changes I need to make here? I've posted the code below:

<%
Dim sCurrentQuarter 'as String
Dim sDataSource 'as String
Dim Server_or_FileName 'as String
Dim sTableDef 'as String
Dim sTableRow 'as String
Dim x 'as Integer
Dim cn 'as ADODB.Connection
Dim rs 'as ADODB.Recordset
Server_or_FileName = &quot;\\MyComputer\MyFolder\MyAccessDB.mdb&quot;
Set cn = CreateObject(&quot;ADODB.Connection&quot;) 'New ADODB.Connection
With cn
.Provider = &quot;Microsoft.Jet.OLEDB.4.0&quot;
.Properties(&quot;Data Source&quot;) = Server_or_FileName
.Open
End With
Set rs = CreateObject(&quot;ADODB.Recordset&quot;)
sDataSource = &quot;SELECT CurrentQuarter From MyTable&quot;
OpenRS sDataSource
sCurrentQuarter = rs.Fields(0).Value
rs.Close
sDataSource = &quot;SELECT * from MyTable&quot;
OpenRS sDataSource
While Not rs.EOF
sTableRow = &quot;<tr>&quot; & vbcrlf
For x = 0 to 3 '4 Fields
sTableRow = sTableRow & &quot;<td align='left'><font size='2' face='Arial'>&quot; & rs.Fields(x).Value & &quot;</font></td>&quot; & vbcrlf
Next
sTableRow = sTableRow & &quot;</tr>&quot; & vbcrlf
sTableDef = sTableDef & sTableRow
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
%>

<html>
<Title>Info~Link DataFiles Log</Title>
<head>
<meta http-equiv=&quot;Content-Language&quot; content=&quot;af&quot;>
<meta name=&quot;GENERATOR&quot; content=&quot;Microsoft FrontPage 5.0&quot;>
<meta name=&quot;ProgId&quot; content=&quot;FrontPage.Editor.Document&quot;>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=windows-1252&quot;>
</head>

<body>

<form method=&quot;POST&quot; action=&quot;--WEBBOT-SELF--&quot;>
<!--webbot bot=&quot;SaveResults&quot; U-File=&quot;fpweb:///_private/form_results.csv&quot; S-Format=&quot;TEXT/CSV&quot; S-Label-Fields=&quot;TRUE&quot; -->
<p align=&quot;center&quot;>
<font color=&quot;#0000FF&quot;><span style=&quot;font-size: 40&quot;><b><i>Page Title - <%=sCurrentQuarter%></i></b></span></font></p>
</form>
<table border=&quot;1&quot; cellpadding=&quot;1&quot; cellspacing=&quot;0&quot; style=&quot;border-collapse: collapse&quot; bordercolor=&quot;#111111&quot; width=&quot;100%&quot; id=&quot;AutoNumber1&quot;>
<tr>
<td width=&quot;15%&quot; align=&quot;center&quot;><font size=&quot;5&quot; color=&quot;#008080&quot;>Field1</font></td>
<td width=&quot;20%&quot; align=&quot;center&quot;><font size=&quot;5&quot; color=&quot;#008080&quot;>Field2</font></td>
<td width=&quot;50%&quot; align=&quot;center&quot;><font size=&quot;5&quot; color=&quot;#008080&quot;>Field3</font></td>
<td width=&quot;15%&quot; align=&quot;center&quot;><font size=&quot;5&quot; color=&quot;#008080&quot;>Field4</font></td>
</tr>
<%=sTableDef%>
</font>
</table>

</body>

</html>

<%
Sub OpenRS(sDataSource)
With rs
.CursorLocation = 3 'adUseServer = 2; adUseClient = 3
.CursorType = 0 'adOpenForwardOnly
.LockType = 1 'adLockReadOnly
.Source = sDataSource
.ActiveConnection = cn
.Open
End With
End Sub
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top