Solved

Sql Exception using ADODB.Recordset with cursor parameters

Posted on 2011-09-28
6
765 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now