Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADODB Recordset MoveFirst error 1

Status
Not open for further replies.

graabein

Programmer
Oct 9, 2002
186
NO
Hi, I get an error trying to MoveFirst on a Recordset. I've been debugging but I can't figure it out... Here's what I've got:
Code:
Set cmd = New ADODB.Command
With cmd
  .ActiveConnection = myConn
  .CommandType = adCmdStoredProc
  .CommandText = "usp_GetDayList
  'Parameters...
End With

Set rs = New ADODB.Recordset
rs.Open cmd, , adOpenDynamic, adLockReadOnly
If rs.State = adStateOpen Then
  Debug.Print "rs.CursorType: " & rs.CursorType
  rs.MoveNext
  rs.MoveNext
  rs.MoveFirst
  'Error!!

That code gives me cursor type adForwardOnly and an error at rs.MoveFirst!!?? Cursor location is server side. I know the returned recordset has more than 3 rows...


[elephant2]
graabein
 
There is some good infor on locks and cursors in this thread thread222-1363106

For some reason your cursor is being manipulated to forward only and forward only cursors can't go back.

I had a similar problem in the thread posted above. The good stuff in towards the end of the thread.
 
Thanks for the link. I've changed my routine to use dynamic client side cursor and rs.MoveFirst works as a charm!

[elephant2]
graabein
 
er, something doesn't sound right.
Are you expecting to update the DB table?

Check the following:

Debug.? rs.CursorType

Debug.? rs.CursorLocation

Debug.? rs.LockType
 
It may be that a recordset can not be updateable if it is created from a stored procedure.

ADO usually changes properties such as cursor type when it thinks your setting is not possible (like changing adOpenDynamic to adForwardOnly).

Joe Schwarz
Custom Software Developer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top