|
-
Jun 13th, 2003, 02:53 AM
#1
Thread Starter
Addicted Member
ADO Error
When I run this script I get the error: Rowset does not support fetching backward.
This error occurs when I try to use the Rst.MoveLast command but I was under the impression that I could do this if I had opened the record set as "Rst.CursorType = adOpenDynamic" obviously I am doing something wrong here can someone point me in the right direction please.
VB Code:
Dim CN As New ADODB.Connection
Dim Cmd As New ADODB.Command
Dim Rst As New ADODB.Recordset
Dim DeviceCount As Integer
Dim Count As Integer
'Open DB Connection
CN.Open DBPath
Set Rst = New ADODB.Recordset
Rst.CursorType = adOpenDynamic
Rst.Supports (adMovePrevious)
'Prepare the user-defined function statement and execute the command.
Cmd.ActiveConnection = CN
Cmd.CommandText = "SELECT DeviceName, DeviceType, CMACNum, Address, PLCID, NumEvents, StartRead, StopRead FROM SOEWFC_Definitions;"
Set Rst = Cmd.Execute
'Check to see if there are any records in the table
If Rst.EOF = False Then
'get number of rows in Backups table
Rst.MoveLast
DeviceCount = Rst.RecordCount
Rst.MoveFirst
End If
-
Jun 13th, 2003, 03:52 AM
#2
Re: ADO Error
Originally posted by mik706
VB Code:
Dim CN As New ADODB.Connection
Dim Cmd As New ADODB.Command
Dim Rst As New ADODB.Recordset
Dim DeviceCount As Integer
Dim Count As Integer
'Open DB Connection
CN.Open DBPath
Set Rst = New ADODB.Recordset
Rst.CursorType = adOpenDynamic
'---- what is this??? I couldn't find help on it - you don't need it!
'Rst.Supports (adMovePrevious)
'Prepare the user-defined function statement and execute the command.
Cmd.ActiveConnection = CN
Cmd.CommandText = "SELECT DeviceName, DeviceType, CMACNum, Address, PLCID, NumEvents, StartRead, StopRead FROM SOEWFC_Definitions;"
'---- why do ppl execute when its open ?
'- can't remember the options flags ;)
'rst.open strSql,cn,option,option,adcmdtext
Set Rst = Cmd.Execute
'---- being picky - but no checks to see whether the db opened? ;) or the recordset opened ;) rst.state=adstateopen
'Check to see if there are any records in the table
If Rst.EOF = False Then
'get number of rows in Backups table
Rst.MoveLast
DeviceCount = Rst.RecordCount
Rst.MoveFirst
End If
Sorry for the extra remarks - ignore if you feel so.
Probably not working as you are executing cmd but not opening the recordset as dynamic (its being reset via the cmd).
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|