Hi,
I have an ASP Page that holds all the functions I created named Function.asp and it looks like this:
Function setCn1(strSQL)
Dim strConn1, rsRecord
strConn1 = "Provider=SQLOLEDB.1; SERVER=SQL1;
UID=ABC; PWD=DEF; Database=DBRecords"
Set rsRecord = Server.CreateObject("ADODB.Recordset")
rsRecord.Open strSQL, strConn1
setCn1 = rsRecord
End Function
I included the Function.asp page to a another ASP Page, say Records.asp.
The function returns as a RecordSet. So from the Records.asp, I call the setCN1 function:
Dim rsRecordFromFunction, strSQL
strSQL = "Select * FROM Table"
Set rsRecordFromFunction = setCn1(strSQL)
Response.Write rsRecordFromFunction ("PhoneNum") & " - "
Response.Write rsRecordFromFunction ("AgentID") & " - "
Response.Write rsRecordFromFunction ("ResultCode")
This works perfectly well. Now my concern is:
1) How do I close the rsRecord from the Function.asp page and set it to nothing without declaring it as a Global Variable in the Records.asp page?
2)If I close and set the rsRecordFromFunction (from the Records.asp page) to Nothing, it gives me an error "Object doesn't support the method...or something". Does this mean that rsRecordFromFunction does not have to be Closed and Set rsRecordFromFunction to Nothing?
3) Is rsRecordFromFunction a recordset too?
Thanks alot
Mike
I have an ASP Page that holds all the functions I created named Function.asp and it looks like this:
Function setCn1(strSQL)
Dim strConn1, rsRecord
strConn1 = "Provider=SQLOLEDB.1; SERVER=SQL1;
UID=ABC; PWD=DEF; Database=DBRecords"
Set rsRecord = Server.CreateObject("ADODB.Recordset")
rsRecord.Open strSQL, strConn1
setCn1 = rsRecord
End Function
I included the Function.asp page to a another ASP Page, say Records.asp.
The function returns as a RecordSet. So from the Records.asp, I call the setCN1 function:
Dim rsRecordFromFunction, strSQL
strSQL = "Select * FROM Table"
Set rsRecordFromFunction = setCn1(strSQL)
Response.Write rsRecordFromFunction ("PhoneNum") & " - "
Response.Write rsRecordFromFunction ("AgentID") & " - "
Response.Write rsRecordFromFunction ("ResultCode")
This works perfectly well. Now my concern is:
1) How do I close the rsRecord from the Function.asp page and set it to nothing without declaring it as a Global Variable in the Records.asp page?
2)If I close and set the rsRecordFromFunction (from the Records.asp page) to Nothing, it gives me an error "Object doesn't support the method...or something". Does this mean that rsRecordFromFunction does not have to be Closed and Set rsRecordFromFunction to Nothing?
3) Is rsRecordFromFunction a recordset too?
Thanks alot
Mike