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

Displaying database records: Unspecified error

Status
Not open for further replies.

j420exe

MIS
Feb 17, 2002
28
US
I am using win2k server, access 2000 and IIS 5. The page will display the contents of the database but when I click refresh I get the unspecified error message and the line reference is to my DSN. I have double checked the DSN and the database and everything seems right. Here is what I have so far:
<%

Dim DataConn, cmdDC, rsDC
Dim Item
Dim iFieldCount, iLoopVar
Dim strSortBy, strOrder

strSortBy = Request.QueryString(&quot;sortby&quot;)
If strSortBy = &quot;&quot; Then strSortBy = &quot;gettime&quot;

strOrder = Request.QueryString(&quot;order&quot;)


' Create and establish data connection
Set DataConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
DataConn.ConnectionTimeout = 15
DataConn.CommandTimeout = 30

'Access connection code
'DataConn.Open &quot;Test&quot;
DataConn.Open &quot;prod_timings&quot;

' Create and link command object to data connection then set attributes and SQL query
Set cmdDC = Server.CreateObject(&quot;ADODB.Command&quot;)
cmdDC.ActiveConnection = DataConn
cmdDC.CommandText = &quot;SELECT * FROM Table1 ORDER BY &quot; & strSortBy & strOrder
cmdDC.CommandType = 1

' Create recordset and retrieve values using command object
Set rsDC = Server.CreateObject(&quot;ADODB.Recordset&quot;)
' Opening record set with a forward-only cursor (the 0) and in read-only mode (the 1)
rsDC.Open cmdDC, , 0, 1
%>
<html>
<head>
<title>Production Timings</title>
</head>
<body>
<p><strong><u>Production Timings Report</u></strong></p>
<p>
<strong>Sorted By: <%= strSortBy %></strong><br>
<strong>Ordered By: <%= strOrder %></strong>
</p>


<table border=&quot;1&quot;>
<thead>
<tr>
<% For Each Item in rsDC.Fields %>
<th bgcolor=&quot;#C0C0C0&quot;><%= Item.Name %></th>
<% Next %>
</tr>
</thead>
<%
' Loop through recordset and display results
If Not rsDC.EOF Then rsDC.MoveFirst

' Get the number of fields and subtract one so our loops start at 0
iFieldCount = rsDC.Fields.Count - 1

' Continue till we get to the end, and while in each <TR> loop through fields
Do While Not rsDC.EOF
%> <tr>
<% For iLoopVar = 0 to iFieldCount %>
<td><%= rsDC.Fields(iLoopVar) %></td>
<% Next %>
</tr>
<%
rsDC.MoveNext
Loop
%>
</table>

<%
' Close Data Access Objects and free DB variables
rsDC.Close
Set rsDC = Nothing

Set cmdDC = Nothing
DataConn.Close
Set DataConn = Nothing
%>

<br>

<strong>Build your own query:</strong>
<form action=&quot;<%= Request.ServerVariables(&quot;URL&quot;) %>&quot; method=&quot;get&quot;>
Sort By:
<select name=&quot;sortby&quot;>
<option value=&quot;gettime&quot;>gettime</option>
<!-- <option value=&quot;dow&quot;>dow</option>
<option value=&quot;month&quot;>month</option>
<option value=&quot;time&quot;>time</option> -->
</select>
<select name=&quot;order&quot;>
<option value=&quot;&quot;>Ascending
<option value=&quot; DESC&quot;>Descending
</select>
<br>
<input type=&quot;submit&quot; value=&quot;Run Query&quot;/>
</form>

</body>
</html>

Any ideas on why the page is erroring out after I hit the refresh button?
 
When was the code last changed?? It could be that the a version with no errors is in browser cache, and when you refresh it is trying to re-execute the script, which now contains an error.

I think i may have had a problem similar to this once, and I was SURE I was not using cache... and it turned out to be that the database and webserver needed to be restarted. (Microsoft products).

You could try that too. Brett Birkett B.Comp
Systems Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top