 Cigaro World Chat Champion
Joined: 28 Mar 2007 Karma :  
|
 Posted: 17:02 - 11 Nov 2008 Post subject: First time using SQl server and ADO. Help...? |
 |
|
Hi,
I have an Access 2002 application which I am converting to use an SQL server backend instead of a .MDB file. I've linked the tables fine, now I'm trying to work out how to change over all the ADO stuff.
This is the problem I have: Using the code below, I cannot get a recordcount - it always returns -1.
I know my cursor on the recordset is OK, is there something extra I need to specify on the connection object?
I know the connection ETC is OK as I can navigate between records, return record values and field counts.
| Code: |
Function TestODBC()
Dim a As New ADODB.Connection
a.Open "driver={SQL Server}; server={vista01\sqlexpress}; database={backend}"
Dim b As New ADODB.Recordset
b.Open "SELECT * FROM Contacts", a, adOpenDynamic, adLockOptimistic
MsgBox b.RecordCount
End Function
|
|
|
 The Shaggy D.A. Super Spammer

Joined: 12 Sep 2008 Karma :  
|
 Posted: 17:11 - 11 Nov 2008 Post subject: |
 |
|
If it returns -1, it may be that the property isn't supported.
https://www.w3schools.com/ado/prop_rs_recordcount.asp ____________________ Chances are quite high you are not in my Monkeysphere, and I don't care about you. Don't take it personally.
Currently : Royal Enfield 350 Meteor
Previously : CB100N > CB250RS > XJ900F > GT550 > GPZ750R/1000RX > AJS M16 > R100RT > Bullet 500 > CB500 > LS650P > Bullet Electra X & YBR125 > Bullet 350 "Superstar" & YBR125 Custom > Royal Enfield Classic 500 Despatch Limited Edition (28 of 200) & CB Two-Fifty Nighthawk > ER5 |
|