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 7 2556
[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" <db****@mvps.org> wrote in message
news:uf*************@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.
Hi Bob. The line that generates the error is adoRS.movefirst however if I
remove that, ANY line that references the recordset generates the error.
For example: var1= adoRS("Field1") would generate the error.
function GetRecords()
---->>> adoRS.movefirst
var1 = adoRS("field1")
...........etc
end function
Code that creates the recordset is in a script block at the top of the page
and the function is in a script block about half way down the page. I'm
calling the function near the end of the page. Getting rid of the Set
adoRS.ActiveConnection line and changing it has no effect.
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:uP**************@TK2MSFTNGP09.phx.gbl... [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" <db****@mvps.org> wrote in message news:uf*************@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.
PS - there's no client side code or script block on the page
"David Berry" <db****@mvps.org> wrote in message
news:eu*************@tk2msftngp13.phx.gbl... Hi Bob. The line that generates the error is adoRS.movefirst however if I remove that, ANY line that references the recordset generates the error. For example: var1= adoRS("Field1") would generate the error.
function GetRecords() ---->>> adoRS.movefirst var1 = adoRS("field1") ...........etc end function
Code that creates the recordset is in a script block at the top of the
page and the function is in a script block about half way down the page. I'm calling the function near the end of the page. Getting rid of the Set adoRS.ActiveConnection line and changing it has no effect.
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message news:uP**************@TK2MSFTNGP09.phx.gbl... [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" <db****@mvps.org> wrote in message news:uf*************@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.
1. Try declaring the function higher up on the page.
2. Try passing the recordset to the function instead of using the global
variable. I.E.,
adoRs.open ...
....
GetRecords(adoRS)
Function GetRecords(pRS)
if not pRS.BOF then pRS.MoveFirst
'etc.
End Function
David Berry wrote: PS - there's no client side code or script block on the page "David Berry" <db****@mvps.org> wrote in message news:eu*************@tk2msftngp13.phx.gbl... Hi Bob. The line that generates the error is adoRS.movefirst however if I remove that, ANY line that references the recordset generates the error. For example: var1= adoRS("Field1") would generate the error.
function GetRecords() ---->>> adoRS.movefirst var1 = adoRS("field1") ...........etc end function
Code that creates the recordset is in a script block at the top of the page and the function is in a script block about half way down the page. I'm calling the function near the end of the page. Getting rid of the Set adoRS.ActiveConnection line and changing it has no effect.
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message news:uP**************@TK2MSFTNGP09.phx.gbl... [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" <db****@mvps.org> wrote in message news:uf*************@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.
--
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.
Hi Bob. I just tried both those and I still get object required 'pRS'
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:er**************@tk2msftngp13.phx.gbl... 1. Try declaring the function higher up on the page. 2. Try passing the recordset to the function instead of using the global variable. I.E.,
adoRs.open ... ... GetRecords(adoRS)
Function GetRecords(pRS) if not pRS.BOF then pRS.MoveFirst 'etc. End Function David Berry wrote: PS - there's no client side code or script block on the page "David Berry" <db****@mvps.org> wrote in message news:eu*************@tk2msftngp13.phx.gbl... Hi Bob. The line that generates the error is adoRS.movefirst however if I remove that, ANY line that references the recordset generates the error. For example: var1= adoRS("Field1") would generate the error.
function GetRecords() ---->>> adoRS.movefirst var1 = adoRS("field1") ...........etc end function
Code that creates the recordset is in a script block at the top of the page and the function is in a script block about half way down the page. I'm calling the function near the end of the page. Getting rid of the Set adoRS.ActiveConnection line and changing it has no effect.
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message news:uP**************@TK2MSFTNGP09.phx.gbl... [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" <db****@mvps.org> wrote in message news:uf*************@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.
-- 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.
Well, I'm stumped. Is there any chance of posting an abbreviated version of
your page in which this error can be reproduced? Use the Northwind sample
database so we don't have to worry about getting sample data from you.
Bob Barrows
David Berry wrote: Hi Bob. I just tried both those and I still get object required 'pRS' "Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message news:er**************@tk2msftngp13.phx.gbl... 1. Try declaring the function higher up on the page. 2. Try passing the recordset to the function instead of using the global variable. I.E.,
adoRs.open ... ... GetRecords(adoRS)
Function GetRecords(pRS) if not pRS.BOF then pRS.MoveFirst 'etc. End Function David Berry wrote: PS - there's no client side code or script block on the page "David Berry" <db****@mvps.org> wrote in message news:eu*************@tk2msftngp13.phx.gbl... Hi Bob. The line that generates the error is adoRS.movefirst however if I remove that, ANY line that references the recordset generates the error. For example: var1= adoRS("Field1") would generate the error.
function GetRecords() ---->>> adoRS.movefirst var1 = adoRS("field1") ...........etc end function
Code that creates the recordset is in a script block at the top of the page and the function is in a script block about half way down the page. I'm calling the function near the end of the page. Getting rid of the Set adoRS.ActiveConnection line and changing it has no effect.
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message news:uP**************@TK2MSFTNGP09.phx.gbl... > [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" <db****@mvps.org> wrote in message > news:uf*************@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.
-- 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.
--
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.
Bob, I'll have to cut it down to post it. It's a huge page. I'll try and
post it tomorrow when I get back to work. Thanks for the help.
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:eB**************@TK2MSFTNGP09.phx.gbl... Well, I'm stumped. Is there any chance of posting an abbreviated version
of your page in which this error can be reproduced? Use the Northwind sample database so we don't have to worry about getting sample data from you.
Bob Barrows
David Berry wrote: Hi Bob. I just tried both those and I still get object required 'pRS' "Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message news:er**************@tk2msftngp13.phx.gbl... 1. Try declaring the function higher up on the page. 2. Try passing the recordset to the function instead of using the global variable. I.E.,
adoRs.open ... ... GetRecords(adoRS)
Function GetRecords(pRS) if not pRS.BOF then pRS.MoveFirst 'etc. End Function David Berry wrote: PS - there's no client side code or script block on the page "David Berry" <db****@mvps.org> wrote in message news:eu*************@tk2msftngp13.phx.gbl... > Hi Bob. The line that generates the error is adoRS.movefirst > however if I remove that, ANY line that references the recordset > generates the error. For example: var1= adoRS("Field1") would > generate the error. > > function GetRecords() > ---->>> adoRS.movefirst > var1 = adoRS("field1") > ...........etc > end function > > Code that creates the recordset is in a script block at the top of > the page and the function is in a script block about half way down > the page. I'm calling the function near the end of the page. > Getting rid of the Set adoRS.ActiveConnection line and changing it > has no effect. > > > "Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message > news:uP**************@TK2MSFTNGP09.phx.gbl... >> [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" <db****@mvps.org> wrote in message >> news:uf*************@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.
-- 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.
-- 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.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Oscar |
last post by:
I am looking for a way to pass an ADO recordset that has been retrieved in
an ASP page to another HTML-page. Is there someone who can provide me with a
small sample or a link to see how this is...
|
by: j.mandala |
last post by:
Someone is trying to run my Access 2002 database under Access 2003. He
has had a number of problems:
1) i used the MSComCt2.ocx for it's Date and Time picker. I can't find
it under 2003. Do I...
|
by: bdt513 |
last post by:
I am trying to extract the values from a query using VBA.
Specifically, I want to concatenate all the values of the "rosEmail"
field from query "qselRosterEmailList" into one string (strEmails). I...
|
by: lenny |
last post by:
Hi,
I've been trying to use a Sub or Function in VBA to connect to a
database, make a query and return the recordset that results from the
query. The connection to the database and the query...
|
by: Rob |
last post by:
I built this nice system, where in a part of the program, I can
actually look up what other functions/procedures I need to call.
Problem is I have no idea how do you call a function whos function...
|
by: kjvt |
last post by:
Based on a prior posting, I've written a function to convert a
recordset to a dataview. The first call to the function for a given
recordset works perfectly, but the second call always returns a...
|
by: Oko |
last post by:
I'm currently developing an MS Access Data Project (.adp) in MS Access
2002.
One of the reports within the DB uses data that is Dynamic and cannot
be stored on the SQL Server. To resolve this, I...
|
by: wallconor |
last post by:
Hi,
I am having a problem using Dreamweaver CS3 standard recordset paging behavior. It doesn’t seem to work when I pass parameter values from a FORM on my search page, to the recordset on my...
|
by: =?Utf-8?B?R1ROMTcwNzc3?= |
last post by:
Hi Guys, thanks for your help yesterday, I've got one more question, then I
think I'm done for now,...
Is it possible to insert recordset data in a javascript, for instance I have
a javascript...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |