Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DAO ODBC Connection

Status
Not open for further replies.

XJ900

Technical User
Apr 13, 2007
27
US
Can anyone tell me how to create a DAO ODBC connection to a MS SQL server?

I can do an ADO connection like so:
Dim conn As adodb.Connection conn.ConnectionString = "driver={SQL SERVER};Server=Williamtell;DATABASE=" & sqldb & ";uid=accpac;pwd=accpac;"
conn.Open

I'm wondering what the DAO equivalent is? Also the reason I want to switch types is because when I run a record count on my ADO connection I get a record count as -1. Even if records are found it still gives me that count. Does anyone know why?

Thanks
 
It gives you a record count of -1 because of the default cursor type. You need to use a keyset cursor to get an actual count. Or use a client-side cursor.

You're better sticking with ADO, especially if you migrate to .Net.

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
Well who knew. That worked perfectly. ArtieChoke you are the man. I appreciate your help!

Thanks
 
Hi Artie,

Keyset cursors aren't fully populated on opening, so they'll suffer from this problem too. In order for a keyset cursor to have an accurate recordcount, you'd need to run through the entire recordset once, otherwise the recordcount will only equal those records actually accessed. (This can be useful too...) Presumably the OP used your second suggestion, since client side cursors are always static.

For more information, see faq222-3670.

HTH

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top