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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with a record set and an ODBC connection

Status
Not open for further replies.

cal555

Programmer
May 5, 2006
71
US
Hi,
I am trying to get this code to work, but it keeps stoping on the cn (Set cn = OpenConnection("", dbDriverComplete, False, scn)) line for the connection to the SQL Server. The error says that the opperation is not supported by this type of object. I got this from a book, As usal I think they are leaving some code out. And I need a way to do this through ODBC, because that is what the company wants.
Here is my code:

Private Sub Form_Load()
Dim db As Database
Dim cn As Connection
Dim rs As Recordset
Dim rs2 As Recordset
Dim scn As String
Dim strsql As String
Dim qd As QueryDef
Dim wkODBCDirect As Workspace

Dim strsql2 As String
Dim qd2 As QueryDef

'Connection String
scn = "ODBC;DRIVER=SQL SERVER;SERVER=BOB-MDTNZL7OFKX;DATABASE=pubs"

Set cn = OpenConnection("", dbDriverComplete, False, scn)

'Creates the record set
Set rs = cn.OpenRecordset("Select * From sales", dbOpenDynaset)

cboStoreID = rs![stor_id]

End Sub
Any help would be really appreaciated
Thank you
 
Thamks but I been there it just gives a shel of a connection and not the one I need. I need a DNS less connection for ODBC direct, and they do not have it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top