473,608 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP, looping, and stored procedures.... error '800a0bb9' ...

Hi all, thanks in advance.

Ok, heres the story.
What is happening......
--------------------------------

I've got an ASP page that loops.
It loops in order to get data in different, sequential date ranges. I.E.
from 9/1/2000 - 10/1/2000 then 10/1/2000 - 11/1/2000 etc etc etc.
It calls SPs using the 2 dates and an integer used for companyid reference.

Let's just do this for 2 SP's (there are like 6 on the page.)
One SP has 3 params, one has only 2.

Now, the first iteration of the loop, it works. (because I'm
response.writit ing out the dates it's using to verify they are ok.
The second time through I get the following error when I try to execute the
following ASP:

Set rstStoredProc = cmdStoredProc.E xecute(, Array(GroupChoi ce, fromdate,
todate))
_______________ _______________ _______________ _
ADODB.Command error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another.

_______________ _______________ _______________ __

What I need to do.........

--------------------

In the loop, I am trying to reuse my command/connection objects instead of
reinstantiating them for each iteration of the loop.
***Currently, it must use ODBC not OLEDB so keep that in mind.***

Here's the code for the SP's
--------------------

CREATE Procedure proc_getPageHit s
(
@GroupID int,
@FromDate datetime,
@ToDate datetime
)
As
SELECT sum(counter) as hitcount
FROM tblTracking
WHERE CreateUserID in (select UserID from tblUser where GroupID=
@GroupID)
and (CreateDate between @FromDate and @ToDate)
GO

CREATE Procedure proc_getUserCou nt
(
@GroupID int,
@ToDate datetime
)
As
SELECT count(UserID) as usercount
FROM tblUser
WHERE (GroupID = @GroupID) and (CreateDate < @ToDate)
GO
Here's the ASP
----------------------------------------------
Set cmdStoredProc = Server.CreateOb ject("ADODB.Com mand")
cmdStoredProc.A ctiveConnection = dbConn

do while DateCompare(cur rentsearchdate, todaysquarteren d) = "smaller"

cmdStoredProc.C ommandText = "Proc_getUserCo unt"
cmdStoredProc.C ommandType = adCmdStoredProc
Set rstStoredProc = cmdStoredProc.E xecute(, Array(GroupChoi ce, todate))

cmdStoredProc.C ommandText = "Proc_getPageHi ts"
cmdStoredProc.C ommandType = adCmdStoredProc
Set rstStoredProc2 = cmdStoredProc.E xecute(, Array(GroupChoi ce,
fromdate, todate)) '(**THIS IS WHERE IT ERRORS**)

loop
----------------------------------------------
Why does it error on the SECOND procedure of the SECOND iteration of the
loop?
It makes it past the first loop ok.
Then it makes it past the first SP of the second loop but errors in the
second SP....??...

The dates are verified correct and in format.... so what the heck is the
prob?

If I re-create the command object each iteration (i.e. put the Set
cmdStoredProc = Server.CreateOb ject("ADODB.Com mand") line inside the loop)
it works fine. but it's so much slower. The results of the page are coming
back in 13seconds. (there's alot more calls and alot more stuff going on,
but these procedures should pick it up a bit.

Also, if you have any suggestions on the SQL select statements, feel free to
enlighten me. I am using the 'IN' method whereas some people have told me of
the 'where exists' SQL method. I have not received any examples though.

Thanks again in advance.
-Beau
www.worlddoc.com


Jul 22 '05 #1
1 3714
Beau wrote:
Hi all, thanks in advance.

Ok, heres the story.
What is happening......
--------------------------------

I've got an ASP page that loops.
It loops in order to get data in different, sequential date ranges.
I.E. from 9/1/2000 - 10/1/2000 then 10/1/2000 - 11/1/2000 etc etc etc.
It calls SPs using the 2 dates and an integer used for companyid
reference.

Let's just do this for 2 SP's (there are like 6 on the page.)
One SP has 3 params, one has only 2.

Now, the first iteration of the loop, it works. (because I'm
response.writit ing out the dates it's using to verify they are ok.
The second time through I get the following error when I try to
execute the following ASP:

Set rstStoredProc = cmdStoredProc.E xecute(, Array(GroupChoi ce,
fromdate, todate))
_______________ _______________ _______________ _
ADODB.Command error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are
in conflict with one another.

_______________ _______________ _______________ __

What I need to do.........

--------------------

In the loop, I am trying to reuse my command/connection objects
instead of reinstantiating them for each iteration of the loop.
You don't need to even use a Command object. You can execute the below
procedures simply by doing this (assuming you've got a connection object
with the sensible name of cn):

set rstStoredProc2 =createobject(" adodb.recordset ")
cn.proc_getPage Hits GroupChoice,fro mdate,todate,rs tStoredProc2
set rstStoredProc =createobject(" adodb.recordset ")
cn.proc_getUser Count GroupChoice,tod ate,rstStoredPr oc
***Currently, it must use ODBC not OLEDB so keep that in mind.***
This is irrelevant, but ... Why is that? I've never seen a good reason for
using the obsolete ODBC driver.

Here's the code for the SP's
--------------------

CREATE Procedure proc_getPageHit s
(
@GroupID int,
@FromDate datetime,
@ToDate datetime
)
As --you forgot to include this:
SET NOCOUNT ON
SELECT sum(counter) as hitcount
FROM tblTracking
WHERE CreateUserID in (select UserID from tblUser where GroupID=
@GroupID)
and (CreateDate between @FromDate and @ToDate)
SELECT sum(counter) as hitcount
FROM tblTracking t INNER JOIN tblUser u
ON t.CreateUserID = u.UserID AND u.GroupID = @GroupID
WHERE t.CreateDate between @FromDate and @ToDate
GO

CREATE Procedure proc_getUserCou nt
(
@GroupID int,
@ToDate datetime
)
As
--Again:
SET NOCOUNT ON SELECT count(UserID) as usercount
FROM tblUser
WHERE (GroupID = @GroupID) and (CreateDate < @ToDate)
GO

Actually, this can be done with a single stored procedure:

CREATE Procedure proc_getUserCou ntAndPageHits (
@GroupID int,
@FromDate datetime,
@ToDate datetime,
@Users int output
)
As
SET NOCOUNT ON
SELECT @users=count(Us erID) as usercount
FROM tblUser
WHERE (GroupID = @GroupID) and (CreateDate < @ToDate)

SELECT sum(counter) as hitcount
FROM tblTracking t INNER JOIN tblUser u
ON t.CreateUserID = u.UserID AND u.GroupID = @GroupID
WHERE t.CreateDate between @FromDate and @ToDate
go

Of course, you are back to needing to use a Command object in order to
retrieve the output parameter value. Also, you will no longer be able to use
the Array method to execute the procedure. You will need to use
CreateParameter statements to create the Parameters collection. I've posted
code for doing this before.

Slightly less efficiently, you can do this to avoid writing the
CreateParameter statements:

CREATE Procedure proc_getUserCou ntAndPageHits (
@GroupID int,
@FromDate datetime,
@ToDate datetime
)
As
SET NOCOUNT ON
EXEC proc_getUserCou nt @GroupID, @ToDate
SELECT sum(counter) as hitcount
FROM tblTracking t INNER JOIN tblUser u
ON t.CreateUserID = u.UserID AND u.GroupID = @GroupID
WHERE t.CreateDate between @FromDate and @ToDate
go

And in ASP:
set rstStoredProc =createobject(" adodb.recordset ")
cn.proc_getUser CountAndPageHit s GroupChoice,fro mdate, _
todate,rstStore dProc2
set rstStoredProc2 = rstStoredProc.N extRecordset

Bob Barrows
PS. .inetserver.asp .db was the only group for which this question was
relevant. There was no need to crosspost to so many groups, especially the
irrelevant ones. I've set the Followup-To to
microsoft.publi c.inetserver.as p.db
--
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 #2

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

Similar topics

3
6577
by: Jarrod Morrison | last post by:
Hi all Im relatively new to using stored procedures and im not sure if it is possible to do what I am trying to do so any help here is greatly appreciated. I am using the variable @MachineName which is obviously the local machine name mainly in this procedure. What is loop through from the first character of the variable to the last and use this data in a select statement. I have included the code below for what I have tried so far but I...
9
10289
by: dtwilliams | last post by:
OK, i'm trying to do some error checking on stored procedures and am following the advise in Erland Sommarskog's 'Implementing Error Handling with Stored Procedures' document. Can anybody help with my stored procedures and why it keeps erroring at the '-- Create new Address Detail stage'? The errorCode value that is being return in my web app is 0, so i'm not even sure why it's even raising the error!! Rather than executing the INSERT...
3
2795
by: Rhino | last post by:
I've spent the last couple of hours trying to figure out how to debug a Java stored procedure and am just going in circles. The last straw came when I got "Cannot open input stream for default" when I launched the IBM Distributed Debugger via D:\IBMDebug>idebug.exe -qdaemon -quiport=8000,8001 First, a bit of background. I am running DB2 V7.2 with Fixpack 9 applied on Windows XP Professional (all critical service applied). I've written...
5
5151
by: Raquel | last post by:
This is a very simple DB2 SQLJ stored procedure. The problem is that it seems to run fine but returns NOTHING. I mean..as if nothing has happened..not resultset is returned. I am passing value 'D11' to :workdept and I have checked in the table that 6 rows should have returned. Any ideas why no resultset is being returned. import java.sql.*; import sqlj.runtime.*; import sqlj.runtime.ref.*; import java.io.*; // Input/Output classes
2
9216
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered problems doing this. I wanted to implemented a generic "Helper" class like this: /** * Helper
11
2598
by: Lyle Fairfield | last post by:
The stored procedure script below is an example of how looping, case statements and output parameters can be used in MS-SQL stored procedures to accomplish things for which we may have had to use VBA code, or automation, in the JET world. Some who have not yet worked with MS-SQL may be interested. The script is indented in reality but I have aligned it all left to make reading easier, (I hope). The Sproc takes an Account ID, an...
2
3323
by: Eli | last post by:
Hi all We currently have a strange problem with calling a Stored Procedure (SQL Database) in our C# Project. The only error I get is "System error" which says a lot :) Background: We have several stored procedures to Insert and update datas in our SQL database. Some stored procedures are smaller (insert datas in only one table) and some of them are quite big (insert datas in several
13
5015
by: JayCallas | last post by:
I know this question has been asked. And the usual answer is don't use cursors or any other looping method. Instead, try to find a solution that uses set-based queries. But this brings up several questions / senarios: * I created several stored procedures that take parameters and inserts the data into the appropriate tables. This was done for easy access/use from client side apps (i.e. web-based).
1
5176
Soniad
by: Soniad | last post by:
Hello, I am calling stored procedure in ASP page as follows : Dim oCmdDim,confirmation,IndRecs Set oCmd = Server.CreateObject("ADODB.Command") With oCmd .ActiveConnection = openconnection() .CommandType = 4
0
8495
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8145
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8330
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6011
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5475
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3960
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4023
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2474
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 we have to send another system
0
1328
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.