I've got a strange problem. When I run the clode below as is, it looks as though it's not creating the RS object.
But when it works when I take everything in the function RSconnect(SQL) and replace the function call with the code thats in the function... so it looks like:
any ideas? I'm at a loss here. The error I'm getting is:
Scott Heath
AIM: orange7288
Code:
<!--#include virtual="\adovbs.inc"-->
<%
url = Request.ServerVariables("url") & "?"
Function displayReport(machine)
'response.Write("machine:" & machine)
SQL = "Select * From machineReports order by ID Asc"
If machine <> "" Then SQL = "Select * from machineReports where machine = '" & machine & "'"
RSconnect(SQL)
If RS.EOF Then
Response.Write("No comments found")
Else
%>
<table width="100%" border="0">
<tr>
<th>Machine</th>
<th>Date</th>
<th>Comment</th>
</tr>
<%
Do while NOT RS.EOF
%>
<tr>
<td><%=RS("machine")%></td>
<td><%=RS("commentDate")%></td>
<td><%=RS("comment")%></td>
</tr>
<%
RS.MoveNext()
Loop
End If
End Function
Function RSconnect(SQL)
Response.Write(SQL & "<BR>")
Set RS = Server.CreateObject("ADODB.Recordset")
RS.ActiveConnection = "dsn=testMachine;"
RS.Source = SQL
RS.CursorType = 0
RS.CursorLocation = 2
RS.LockType = 3
RS.Open
End Function
'============================================================
Select Case Request.QueryString("act")
Case "showReport"
machine = request.QueryString("machine")
displayReport(machine)
End Select
%>
But when it works when I take everything in the function RSconnect(SQL) and replace the function call with the code thats in the function... so it looks like:
Code:
<!--#include virtual="\adovbs.inc"-->
<%
url = Request.ServerVariables("url") & "?"
Function displayReport(machine)
'response.Write("machine:" & machine)
SQL = "Select * From machineReports order by ID Asc"
If machine <> "" Then SQL = "Select * from machineReports where machine = '" & machine & "'"
Response.Write(SQL & "<BR>")
Set RS = Server.CreateObject("ADODB.Recordset")
RS.ActiveConnection = "dsn=testMachine;"
RS.Source = SQL
RS.CursorType = 0
RS.CursorLocation = 2
RS.LockType = 3
RS.Open
If RS.EOF Then
Response.Write("No comments found")
Else
%>
<table width="100%" border="0">
<tr>
<th>Machine</th>
<th>Date</th>
<th>Comment</th>
</tr>
<%
Do while NOT RS.EOF
%>
<tr>
<td><%=RS("machine")%></td>
<td><%=RS("commentDate")%></td>
<td><%=RS("comment")%></td>
</tr>
<%
RS.MoveNext()
Loop
End If
End Function
Function RSconnect(SQL)
Response.Write(SQL & "<BR>")
Set RS = Server.CreateObject("ADODB.Recordset")
RS.ActiveConnection = "dsn=testMachine;"
RS.Source = SQL
RS.CursorType = 0
RS.CursorLocation = 2
RS.LockType = 3
RS.Open
End Function
'============================================================
Select Case Request.QueryString("act")
Case "showReport"
machine = request.QueryString("machine")
displayReport(machine)
End Select
%>
any ideas? I'm at a loss here. The error I'm getting is:
Code:
Microsoft VBScript runtime error '800a01a8'
Object required: 'RS'
/testreport/default.asp, line 60
Scott Heath
AIM: orange7288