|
-
December 23rd, 1999, 06:36 AM
#1
How to set up an ODBC Conection
I would like to obtain some code to automatic set up an ODBC conection by calling the interface API of windows.
-
January 17th, 2000, 06:50 PM
#2
Re: How to set up an ODBC Conection
Try this code. It will set up a user odbc driver for an sql database.
Dim rc as Long
'Allocate environment for the driver
rc = SQLAllocEnv(hwnd)
If rc <> 0 then
MsgBox "Unable to allocate environment."
End
End If
rc = SQLConfigDataSource(0, 1, "SQL Server", _
"DSN=" & Driver & Chr(0) & _
"Server=" & IPAddress & Chr(0) & _
"Database=" & Chr(0) & _
"UseProcForPrepare=Yes" & Chr(0) & _
"Description=" & Chr(0) & Chr(0))
-
January 17th, 2000, 06:52 PM
#3
Re: How to set up an ODBC Conection
Oops
Don't forget to put this in a module to declare
the dll.
public Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" (byval HM as Integer, byval Rq as Integer, byval Driver as string, byval Connect as string) as Integer
-
January 18th, 2000, 02:15 AM
#4
Re: How to set up an ODBC Conection
You don't need to call SQLAllocConv in order to call SQLConfigDataSource.
If you call it, you should also call SQLFreeEnv, and, the return value is not a return code, but a HENV - an environment handle.
-
January 18th, 2000, 02:17 AM
#5
Re: How to set up an ODBC Conection
you can use the RegisterDatabase method of the DAO object model, or use the "ODBC Driver and Data Source Name functions" Typelib that comes with VB 6's APE (Application Performance Explorer)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|