473,508 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple recordsets on the same Data Connection??

I want to pull 2 different recordsets using 2 different stored
procedures using the same Data Connection. Below is the code that I
currently have, but I'm getting an 'Object Required' error message. Am
I doing this correctly, or at least headed in the right direction? Can
someone tell me the most efficient way (provide a code example) to pull
2 different recordsets from the same Data Connection?

Set dConn = Server.CreateObject("ADODB.Connection")
dConn.Open Application("Some_ConnectionString")

set rsStats = Server.CreateObject("ADODB.recordset")
rsStats = dConn.Execute("exec sp_ReturnSomeRecords " & _
"@Month='" & StatMonth & "'," & _
"@Year='" & StatYear & "'")
set rsMonthTotal = Server.CreateObject("ADODB.recordset")
rsMonthTotal = dConn.Execute("exec sp_ReturnRecordsFromAnotherTbl " & _
"@Month='" & StatMonth & "'," & _
"@Year='" & StatYear & "'")

Thanks in advance!!

Jul 22 '05 #1
3 2689
sa*******@yahoo.com wrote:
I want to pull 2 different recordsets using 2 different stored
procedures using the same Data Connection. Below is the code that I
currently have, but I'm getting an 'Object Required' error message. Am
I doing this correctly, or at least headed in the right direction? Can
someone tell me the most efficient way (provide a code example) to
pull 2 different recordsets from the same Data Connection?

Set dConn = Server.CreateObject("ADODB.Connection")
dConn.Open Application("Some_ConnectionString")

set rsStats = Server.CreateObject("ADODB.recordset")
rsStats = dConn.Execute("exec sp_ReturnSomeRecords " & _
"@Month='" & StatMonth & "'," & _
"@Year='" & StatYear & "'")
This should be
Set rsStats=dConn...

You don't need the first "Set rsStats = ..." line.
Same below


set rsMonthTotal = Server.CreateObject("ADODB.recordset")
rsMonthTotal = dConn.Execute("exec sp_ReturnRecordsFromAnotherTbl " &
_ "@Month='" & StatMonth & "'," & _
"@Year='" & StatYear & "'")

Thanks in advance!!


You should not use te "sp_" prefix for non-system stored procedures. SQL
Server expects procedures with that prefix to be system procedures and
therefore looks first in the Master database for them, only looking in the
default database when tey are not found in Master. It's a slight performance
penalty, and also can be confusing to somebody maintaining your code.

You may want to take a look at this:
http://tinyurl.com/jyy0

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #2
Thanks Bob, but when the page initially loads I get:

Microsoft VBScript runtime error '800a000d'

Type mismatch

I get this for the second recordset (rsMonthTotal). But when I hit the
"January" button to feed the parameters and reload the page it works.
I'm not understanding why I'm getting Type Mismatch on initial load and
then it works when I submit the parameters b/c the code to make the
data call only runs upon 'Submit' having a value...and obviouslyupon
initial load it does not. Thoughts??

Jul 22 '05 #3
sa*******@yahoo.com wrote:
Thanks Bob, but when the page initially loads I get:

Microsoft VBScript runtime error '800a000d'

Type mismatch

I get this for the second recordset (rsMonthTotal). But when I hit the
"January" button to feed the parameters and reload the page it works.
I'm not understanding why I'm getting Type Mismatch on initial load
and then it works when I submit the parameters b/c the code to make
the data call only runs upon 'Submit' having a value...and
obviouslyupon initial load it does not. Thoughts??


What is the line that produces this error? It sounds as if you need to us an
If statement to only allow that line to run if there is data ...

--
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.
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3202
by: shank | last post by:
I have a recordset that contains multiple records of product a user is purchasing. For clarity, I converted the recordset fields to variables. I need to take that entire recordset and insert it...
4
3003
by: dmiller23462 | last post by:
So here's my problem.....I need to set up different email distributions based on which option in the following Select form has been chosen....For instance if "Putaway" is chosen it needs to email...
22
6070
by: James Cane | last post by:
Here's an interesting problem that someone might have an answer to... Some time ago, I wrote a set of utility classes which wrap up the custom row source function needed to add arbitrary items to...
8
6686
by: Tull Clancey | last post by:
Hi, hope someone can help. I'm writing a decent size app as a first project in Net, have been writing in VB for years. I've stumbled on a small problem, I can't open two connections to a...
12
17614
by: Scott | last post by:
Front-end Access 2000 I have a stored procedure that has 2 parameters BusinessUnitID and Year. It returns multiple record sets (5 to be exact). I thought I could use a Pass through query but...
16
5684
by: Randy Harris | last post by:
I was inspired by the recent discussion of returning multiple recordsets to ADO from a stored procedure. (Amazed is probably more accurate). I asked about how to accomplish same with Oracle and...
24
8461
by: Donald Grove | last post by:
I want to populate an array with values from an ado recordset (multiple rows) I use the absolute position of the cursor in the recordset to define the row of my array to be populated. I have a...
0
2348
by: nachiket2k2 | last post by:
Hi, I am using VB 6.0, ADO 2.0 with MS Access 2000 Database. in a vb form, i need to fatch data from 3 different tables (ABC.MDB). it will be a tedious job if i create 3 connections with 3...
4
7335
by: Harshe | last post by:
hello all, I am trying to code, but i am just stuck after importing one sheet. so here is the gist of what i need help with. In a workbook at the start of the year (january) i will have 4...
0
7225
marktang
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,...
1
7042
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7495
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5052
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3181
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1556
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.