Link to home
Start Free TrialLog in
Avatar of Daniel Wilson
Daniel WilsonFlag for United States of America

asked on

ADODB Recordset.Open occassionally raising Error 5 - w/ adOpenKeyset, adLockOptimistic

Related question: http:/Q_24813268.html

In a VB6 application using ADODB, I have 1 point at which 1 customer sometimes gets Error 5,  Invalid procedure call or argument.

We have a function for calling Recordset.Open, and it's in the code hundreds of places and working fine.  Abridging very slightly, we have:

set rs = OpenDBConnection(sqlString, adOpenKeyset, adLockOptimistic)
which has ...

1000         Set ss = New Recordset
1020         ss.Open sqlString, gCn, CursorType, LockType

And in that one instance ... line 1020 sometimes raises Error 5

It's not an error assembling the sql, as that is assembled before the call to the function.  It doesn't appear to be an error in the SQL, as error 5 is a VB6 error, not a SQL Server error.

I can't have a Command object do the Execute for me here, as I need the recordset to be updateable. I know ... not the best data access model, but this has been working for a long time and is scheduled for a rewrite into .Net pretty soon, so an overhaul in VB6 doesn't appear worthwhile.

Has anyone else seen this before?

Any good ideas on resolving it?

Thanks!
Avatar of Brook Braswell
Brook Braswell
Flag of United States of America image

In these cases I would have opened the RS as static rather than as keyset
Avatar of Daniel Wilson

ASKER

Not if you have to write back to it.  I have to be able to write back to the DB in this case ... which you can't do with a Static recordset.

I use adOpenStatic, adLockReadOnly whenever I can -- but here I can't.

Other suggestions?
ASKER CERTIFIED SOLUTION
Avatar of northfields
northfields

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK, trying adOpenDynamic, adLockOptimistic

I will have to quit using RecordCount, but I can work around that.

I'll let you know how it goes ... will take a few hours to get it checked out.

thanks.
Could you not just Get your data in this fashion and then just run an update sql using your connection?
>>Could you not just Get your data in this fashion and then just run an update sql using your connection?

Certainly ... if I'm willing to overhaul a 900-line function in a module that's going to be rewritten completely next year anyway.

I'm trying not to go there ...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
adOpenDynamic seems to have solved it.

And, yes, I'm getting my recordcount using a separate Select Count() query.

Thanks!