Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

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

Simple recordset returns -1 as its recordcount

Hi i am simply trying to create a ado recordset using the Like exprerssion in my sql statement i am using VB6 to Access97 db.

        Set rsSYS = New ADODB.Recordset
        SqlGet = "SELECT tblFFList.FileID, tblFFList.FileFullPath" _
                    & " From tblFFList " _
                    & " WHERE (((tblFFList.FileFullPath) Like '*DS System State Backup*'));"
        rsSYS.Open SqlGet, cn, adOpenDynamic, adLockOptimistic
        rsSYS.MoveFirst

now rsSys.recount = -1
and when i get to rsSys.movefirst i get this error
"3021  Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record."

this is driving me nuts, i need to search this field to return all records that have this in "DS System State Backup"
Now i can get the qry to run fine inside access, it is just when i try and create the recordset in vb

thanks
0
CraigLazar
Asked:
CraigLazar
  • 3
  • 2
  • 2
  • +2
1 Solution
 
vinnyd79Commented:
Set rsSYS = New ADODB.Recordset
rsSYS.CursorLocation = adUseClient  ' < ---  add this
0
 
vinnyd79Commented:
Or maybe:

        Set rsSYS = New ADODB.Recordset
        rsSYS.CursorLocation = adUseClient
        SqlGet = "SELECT tblFFList.FileID, tblFFList.FileFullPath" _
                    & " From tblFFList " _
                    & " WHERE (((tblFFList.FileFullPath) Like '%DS System State Backup%'));"
        rsSYS.Open SqlGet, cn, adOpenDynamic, adLockOptimistic
        rsSYS.MoveFirst
0
 
learnCommented:
You don't need adUseClient, but you shoud use % instead * in ADO.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Leigh PurvisDatabase DeveloperCommented:
To avoid the recordcount of -1 no matter how many records are returned you'll likely need a recordsettype of adOpenKeyset
or
adOpenStatic

But indeed - you're probably getting no records back because of the wrong wildcard use.
0
 
learnCommented:
And may be ADO cannot work with Access97?
0
 
Leigh PurvisDatabase DeveloperCommented:
Yeah - no problem.
ADO using the Jet4 provider - and that can use 97 format mdbs very well.
0
 
ptan218Commented:
The easiest way is to MoveLast then get record counts.
0
 
Leigh PurvisDatabase DeveloperCommented:
Well, that shouldn't be necessary.
An ADO recordset should provide the correct count without manually moving to the end first.
But even moving to the end won't help you if the cursor type isn't appropriate.  You'll still get -1

(Access doesn't support adOpenDynamic cursors).
0
 
CraigLazarAuthor Commented:
hi guys,
thanks so much for the input, i will test it today and let u know

thanks

cheers
0
 
CraigLazarAuthor Commented:
thanks for all the help guys
i managed to get it working with the % sign instead of the *

keep well
and thanks for the help
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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