
September 24th, 2004, 08:58 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
|
|
1. Create a unit called ODBC.pas and add the following into the file:
Code:
unit ODBC;
interface
uses
Windows;
Const
ODBC_ADD_DSN=1;
ODBC_CONFIG_DSN=2;
ODBC_REMOVE_DSN=3;
ODBC_ADD_SYS_DSN=4;
ODBC_CONFIG_SYS_DSN=5;
ODBC_REMOVE_SYS_DSN=6;
ODBC_REMOVE_DEFAULT_DSN=7;
function SQLConfigDataSource(HwndParent:HWND;FRequest:WORD;Driver:PChar;
Attributes:Pchar):boolean;Stdcall;
function SQLGetInstalledDrivers(Size:String;Buff:WORD;BuffOut:WORD):boolean;Stdcall;
implementation
function SQLConfigDataSource;external 'odbccp32.dll' name 'SQLConfigDataSource';
function SQLGetInstalledDrivers;external 'odbccp32.dll' name 'SQLGetInstalledDrivers';
end.
2. In your program, put ODBC in your uses clause.
3. To add the datasource, do something like this:
Code:
SqlConfigDataSource(Handle, ODBC_ADD_DSN,Name of ODBC driver, Driver Parameters ending with NULL character);
For example:
SqlConfigDataSource(0, ODBC_ADD_DSN, 'Microsoft Access Driver (*.mdb)', 'DSN=somename\0 Database=c:/path/to/file.mdb\0 uid=username\0 pwd=somepassword\0');
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
Puzzle of the Month solved by Keath and KevinADC, superior perl programmers of the month
|