VB6 - Negative recordcounts

Hi Experts
I'm getting negative recordcounts with this SQL query and can't run logic based on it

It's a VB6 app connecting to a SQL server file via a connection string. ie:
cn.ConnectionString = "Provider=SQLNCLI.1;Integrated Security=SSPI;" & _
        "Persist Security Info=False;" & _
        "AttachDBFileName=c:\BPSSAMPLES3.mdf;Data Source=peter-84s5hz3wy\SQLEXPRESS"
Everything runs nicely, except when i need to make a variable T/F based on the recordcount. No matter the nr of corresponding records in the table, the rs.recordcount always returns -1.  rs doesn't allow rr.nomatch or rr.movefirst either, so i'm stuck for determining match / nomatch.

 many thanks


Dim rs As ADODB.Recordset 'recordset
Set rs = New ADODB.Recordset
rs.Open "Select * from DIABETES where InternalID = " & currentnr, cn
                Debuglist.AddItem "Recordcount for " & currentnr & " = " & rs.RecordCount
               '*recordcount always comes out as -1 so the following logic never works properly
                If rs.RecordCount = 0 Then
                    DSWORK("PD_Diabetic") = False
                    DSWORK("PD_Diabetic") = True
                End If

Open in new window

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.

are you sure you can connect to the database?
pls go to http://www.connectionstrings.com for the correct connection string.
peterdarazsAuthor Commented:
It certainly does connect and i'm able to populate alll my access tables correctly (except when the logic requires the recordcount.) If you don't mind, i'm going to allow this question to linger a little and see what else comes up by way of answers. many thanks
Ryan ChongSoftware Team Lead, ex-Business Systems Analyst , ex-Senior Application EngineerCommented:
try set the CursorLocation to adUseClient


Set rs = New ADODB.Recordset

rs.CursorLocation = adUseClient

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
ryancys's answer could be it. CursorLocation determines whether your returning data or not, you should set the CursorLocation to adusec.lient
peterdarazsAuthor Commented:
Thanks Guys - This certainly looks like the answer.

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
Microsoft Development

From novice to tech pro — start learning today.