Re: Use a recordset inside a Function?
From: Bob Barrows [MVP] (reb01501_at_NOyahoo.SPAMcom)
Date: 06/23/04
- Next message: David Berry: "Re: Use a recordset inside a Function?"
- Previous message: Jeff Cochran: "Re: ASP vs ASP.NET"
- In reply to: David Berry: "Use a recordset inside a Function?"
- Next in thread: David Berry: "Re: Use a recordset inside a Function?"
- Reply: David Berry: "Re: Use a recordset inside a Function?"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 23 Jun 2004 15:47:10 -0400
[Please don't post in HTML]
I don't see anything wrong. Perhaps if you showed us which line generates
the error ...
I do have some suggestions which I will put inline
Bob Barrows
"David Berry" <dberry@mvps.org> wrote in message
news:ufZZ4SVWEHA.556@tk2msftngp13.phx.gbl...
> 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
This line is unnecessary. If forced to use it, it should be as follows
Set adoRS.ActiveConnection = adoCN
>
> adoRS.CursorLocation = adUseClient
>
> strSQL = "SELECT ... "
> adoRS.open strSQL
>
If you get rid of the "Set adoRS.ActiveConnection ... " line, then you need
to change this to
adoRS.open strSQL,adoCN,,,adCmdText
Otherwise, it should be:
adoRS.open strSQL,,,,adCmdText
> 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
Again, nothing sticks out. Is this function in the same script block? You
haven't tried to use a server-side object in a client-side script block,
have you?
-- Microsoft MVP -- ASP/ASP.NET Please reply to the newsgroup. The email account listed in my From header is my spam trap, so I don't check it very often. You will get a quicker response by posting to the newsgroup.
- Next message: David Berry: "Re: Use a recordset inside a Function?"
- Previous message: Jeff Cochran: "Re: ASP vs ASP.NET"
- In reply to: David Berry: "Use a recordset inside a Function?"
- Next in thread: David Berry: "Re: Use a recordset inside a Function?"
- Reply: David Berry: "Re: Use a recordset inside a Function?"
- Messages sorted by: [ date ] [ thread ]