Solved

Sql Exception using ADODB.Recordset with cursor parameters

Posted on 2011-09-28
6
804 Views
Last Modified: 2012-05-12
Found sql exception errors as follows:

Error: 156, Severity: 15, State: 1
Error: 16937, Severity: 16, State: 1
Error: 16945, Severity: 16, State: 2

The asp code is as follows:

rs = server.createobject("ADODB.Recordset")
rs.open sql, connectionstring, adOpenstatic, adLockReadOnly, adCmdUnknown

The actual call in the sql trace looks like this.

declare @p1 int
set @p1=0
declare @p3 int
set @p3=557064
declare @p4 int
set @p4=98305
declare @p5 int
set @p1=0
exec sp_cursoropen @p1 output, N'exec sql',@p3 output,@p4 output,@p5 output
select @p1, @p3, @p4, @p5

Not sure if these exceptions are real or not since it does appear to return data.  If I remove the parameters off the rs.open and just have the sql command it does not error.  I have tried setting the parameters in different ways but it does not appear to make a difference.
0
Comment
Question by:ws11
  • 3
  • 3
6 Comments
 
LVL 10

Expert Comment

by:plummet
ID: 36718894
Hi,

Are you setting the value of the parameters somewhere? ie

Const adOpenStatic = 3
Const adLockReadOnly = 1
Const adCmdUnknown = 8

The default is adCmdUnknown anyway so there's no need to specify.

0
 

Author Comment

by:ws11
ID: 36719004
yes I have tried to hardcode them in and it does not matter

I think it is something to do with sp_cursoropen.  I am not sure that is even valid in 2008.
0
 
LVL 10

Expert Comment

by:plummet
ID: 36719015
What's the SQL you're sending?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:ws11
ID: 36719072
it is usally a stored procedure
0
 
LVL 10

Accepted Solution

by:
plummet earned 500 total points
ID: 36719326
I'd usually open this sort of recordset forward only, which is readonly by its nature. And the fastest way to open a recordset:

Const adOpenForwardOnly = 0

rs.open sql, connectionstring, adOpenForwardOnly


0
 

Author Comment

by:ws11
ID: 36815168
Yes that did eliminate the sp_cursoropen.  Thanks.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question