Click to See Complete Forum and Search --> : connection error on second recordset


LuigiX
02-06-2004, 04:03 AM
Hi again

I'm trying to open an asp page with two recordsets on it and getting the dreaded "unspecified error" on the folowing line:


rsTask.ActiveConnection = MM_myAssets_STRING


This is the second recordset on the page. The DSN connection "myAssets" has been tested and is working okay.

The code to the offending line is as follows:


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/myAssets.asp" -->
<%
Dim rsType__MMColParam
rsType__MMColParam = "1"
If (Request.Form("category") <> "") Then
rsType__MMColParam = Request.Form("category")
End If
%>
<%
Dim rsType
Dim rsType_numRows

Set rsType = Server.CreateObject("ADODB.Recordset")
rsType.ActiveConnection = MM_myAssets_STRING
rsType.Source = "SELECT DISTINCT type FROM data WHERE category = '" + Replace(rsType__MMColParam, "'", "''") + "'"
rsType.CursorType = 0
rsType.CursorLocation = 2
rsType.LockType = 1
rsType.Open()

rsType_numRows = 0
%>
<%
Dim rsTask__MMColParam
rsTask__MMColParam = "1"
If (Request.Form("category") <> "") Then
rsTask__MMColParam = Request.Form("category")
End If
%>
<%
Dim rsTask
Dim rsTask_numRows

Set rsTask = Server.CreateObject("ADODB.Recordset")
rsTask.ActiveConnection = MM_myAssets_STRING


Any help would be muchos appreciated

Cheers

Luigi

slyfox
02-06-2004, 06:42 AM
try closing the previous connection before opening a new one..

buntine
02-06-2004, 08:02 AM
What is your connection object?

You should have set an ADO connection object.

LuigiX
02-06-2004, 01:40 PM
HI Guys

My connection object is contained in the myAssets.asp file which is called from this page and looks like this:


<%
' FileName="Connection_odbc_conn_dsn.htm"
' Type="ADO"
' DesigntimeType="ADO"
' HTTP="true"
' Catalog=""
' Schema=""
Dim MM_myAssets_STRING
MM_myAssets_STRING = "dsn=conAssets;"
%>


It tests okay.

The real strange thing is the code usually trips on the second rs.activeconnection line (rsTask)


rsTask.ActiveConnection = MM_myAssets_STRING


but occasionally sticks on the first one on that page (rsType)


rsType.ActiveConnection = MM_myAssets_STRING


Hey Sly you might be onto something there with that close thang.

Where and what would you put on the page to do it?

Cheers

Luigi