Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 843
  • Last Modified:

Sql Exception using ADODB.Recordset with cursor parameters

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
ws11
Asked:
ws11
  • 3
  • 3
1 Solution
 
plummetCommented:
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
 
ws11Author Commented:
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
 
plummetCommented:
What's the SQL you're sending?
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
ws11Author Commented:
it is usally a stored procedure
0
 
plummetCommented:
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
 
ws11Author Commented:
Yes that did eliminate the sp_cursoropen.  Thanks.
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now