D
David Berry
I'm trying to use a recordset inside of a function but I'm getting an "object required 'adoRS" error.
At the top of the page I create my recordset, ex:
dim strConnection, adoCN, adoRS, strSQL
strConnection = <Connection>
Set adoCN = server.CreateObject("ADODB.connection")
Set adoRS = server.CreateObject("ADODB.recordset")
adoCN.Open strConnection
adoRS.ActiveConnection = adoCN
adoRS.CursorLocation = adUseClient
strSQL = "SELECT ... "
adoRS.open strSQL
then further down the page I call a function GetRecords(). The function looks like this:
function GetRecords()
adoRS.movefirst
var1 = adoRS("field1")
...........etc
end function
I'd rather not have the whole recordset inside of the function since I also use it on other parts of the page. What am I doing wrong?
Thanks
At the top of the page I create my recordset, ex:
dim strConnection, adoCN, adoRS, strSQL
strConnection = <Connection>
Set adoCN = server.CreateObject("ADODB.connection")
Set adoRS = server.CreateObject("ADODB.recordset")
adoCN.Open strConnection
adoRS.ActiveConnection = adoCN
adoRS.CursorLocation = adUseClient
strSQL = "SELECT ... "
adoRS.open strSQL
then further down the page I call a function GetRecords(). The function looks like this:
function GetRecords()
adoRS.movefirst
var1 = adoRS("field1")
...........etc
end function
I'd rather not have the whole recordset inside of the function since I also use it on other parts of the page. What am I doing wrong?
Thanks