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
LVL 4
CraigLazarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
learnCommented:
You don't need adUseClient, but you shoud use % instead * in ADO.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.