Miki1
December 23rd, 1999, 05:36 AM
I would like to obtain some code to automatic set up an ODBC conection by calling the interface API of windows.
|
Click to See Complete Forum and Search --> : How to set up an ODBC Conection Miki1 December 23rd, 1999, 05:36 AM I would like to obtain some code to automatic set up an ODBC conection by calling the interface API of windows. sonman January 17th, 2000, 05:50 PM 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)) sonman January 17th, 2000, 05:52 PM 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 Lothar Haensler January 18th, 2000, 01:15 AM 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. Lothar Haensler January 18th, 2000, 01:17 AM 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) codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |