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

ODCB

Status
Not open for further replies.

ironmunk

Technical User
Aug 21, 2001
51
CA
Any suggestions on how I could us VB to use a ODBC connection? I created the ODBC connection in control panel and would like VB to use that. I don't want to specify the path of the DB, I want it to obtain the data from the ODBC.

TIA
 
Something like this:-

c = "DRIVER= SQL Server;SERVER=sbs;UID=sa;PWD=;DATABASE=CorbyChilled"

Set db = New Connection
db.CursorLocation = adUseClient
db.Open c Peter Meachem
peter@accuflight.com
 
In this I just called the DSN "Nwind", just substitute your DSN name.


Dim objConn WithEvents as ADODB.Connection

Form_Load()
Set objConn = New ADODB.Connection
objConn.ConnectionString = "PROVIDER = SQLOLEDB.1;" & _
"DSN = Nwind; User ID = sa; Password = "
objConn.Open

If objConn.State = adStateOpen Then
MsgBox "Connection successful!"
Else
MsgBox "Sorry the connection is not successful!"
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top