Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sql Exception using ADODB.Recordset with cursor parameters

Posted on 2011-09-28
6
Medium Priority
?
835 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

Author Comment

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

Accepted Solution

by:
plummet earned 2000 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

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…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

715 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