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 = "\\MyComputer\MyFolder\MyAccessDB.mdb"
Set cn = CreateObject("ADODB.Connection" 'New ADODB.Connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Data Source" = Server_or_FileName
.Open
End With
Set rs = CreateObject("ADODB.Recordset"
sDataSource = "SELECT CurrentQuarter From MyTable"
OpenRS sDataSource
sCurrentQuarter = rs.Fields(0).Value
rs.Close
sDataSource = "SELECT * from MyTable"
OpenRS sDataSource
While Not rs.EOF
sTableRow = "<tr>" & vbcrlf
For x = 0 to 3 '4 Fields
sTableRow = sTableRow & "<td align='left'><font size='2' face='Arial'>" & rs.Fields(x).Value & "</font></td>" & vbcrlf
Next
sTableRow = sTableRow & "</tr>" & 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="Content-Language" content="af">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
<body>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="fpweb:///_private/form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="center">
<font color="#0000FF"><span style="font-size: 40"><b><i>Page Title - <%=sCurrentQuarter%></i></b></span></font></p>
</form>
<table border="1" cellpadding="1" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<tr>
<td width="15%" align="center"><font size="5" color="#008080">Field1</font></td>
<td width="20%" align="center"><font size="5" color="#008080">Field2</font></td>
<td width="50%" align="center"><font size="5" color="#008080">Field3</font></td>
<td width="15%" align="center"><font size="5" color="#008080">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
%>
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 = "\\MyComputer\MyFolder\MyAccessDB.mdb"
Set cn = CreateObject("ADODB.Connection" 'New ADODB.Connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Data Source" = Server_or_FileName
.Open
End With
Set rs = CreateObject("ADODB.Recordset"
sDataSource = "SELECT CurrentQuarter From MyTable"
OpenRS sDataSource
sCurrentQuarter = rs.Fields(0).Value
rs.Close
sDataSource = "SELECT * from MyTable"
OpenRS sDataSource
While Not rs.EOF
sTableRow = "<tr>" & vbcrlf
For x = 0 to 3 '4 Fields
sTableRow = sTableRow & "<td align='left'><font size='2' face='Arial'>" & rs.Fields(x).Value & "</font></td>" & vbcrlf
Next
sTableRow = sTableRow & "</tr>" & 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="Content-Language" content="af">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
<body>
<form method="POST" action="--WEBBOT-SELF--">
<!--webbot bot="SaveResults" U-File="fpweb:///_private/form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p align="center">
<font color="#0000FF"><span style="font-size: 40"><b><i>Page Title - <%=sCurrentQuarter%></i></b></span></font></p>
</form>
<table border="1" cellpadding="1" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<tr>
<td width="15%" align="center"><font size="5" color="#008080">Field1</font></td>
<td width="20%" align="center"><font size="5" color="#008080">Field2</font></td>
<td width="50%" align="center"><font size="5" color="#008080">Field3</font></td>
<td width="15%" align="center"><font size="5" color="#008080">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
%>