Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dynamic ODBC DSN(Access) creation thru Delphi code

287 views
Skip to first unread message

skumar

unread,
Oct 15, 2001, 12:02:34 AM10/15/01
to
HI!

Can anybody help me on creation of an MS Access ODBC DSN creation on the flu
thru Delphi code?

Thanks in advance!


Steve Moran

unread,
Oct 15, 2001, 7:46:56 AM10/15/01
to
www.odbcexpress.com Administrator component. It's not free, but there is a
free trial version.

Steve

"skumar" <sku...@gseindia.com> wrote in message news:3bca5f4e_1@dnews...

Brion L. Webster

unread,
Oct 15, 2001, 11:39:53 AM10/15/01
to
"skumar" <sku...@gseindia.com> wrote...

> Can anybody help me on creation of an MS Access ODBC DSN creation on the flu
> thru Delphi code?
>

www.tamaracka.com is a great site to search for things like this. Searching
on Create DSN brought up this code:

To: "Lnd" <v...@pulkovo.ru>
From: "M.H. Avegaart" <aveg...@NOSPAMmccomm.nl>
Subject: Re: ODBC How create dsn from my application? Help please....
Date: Tue, 15 May 2001 14:20:21 +0200
Groups: borland.public.delphi.winapi
The following example demonstrates creating and removing MS Access DSNs at
run-time:

const
ODBC_ADD_DSN = 1; // Add data source
ODBC_CONFIG_DSN = 2; // Configure (edit) data
ODBC_REMOVE_DSN = 3; // Remove data source
ODBC_ADD_SYS_DSN = 4; // add a system DSN
ODBC_CONFIG_SYS_DSN = 5; // Configure a system DSN
ODBC_REMOVE_SYS_DSN = 6; // remove a system DSN
ODBC_REMOVE_DEFAULT_DSN = 7; // remove the default DSN

function SQLConfigDataSource(
hwndParent: HWND;
fRequest: WORD;
lpszDriver: LPCSTR;
lpszAttributes: LPCSTR): BOOL; stdcall; external 'ODBCCP32.DLL';

procedure CreateDSN;
begin
SQLConfigDataSource(0, ODBC_ADD_DSN,
'Microsoft Access Driver (*.mdb)', PChar(
'DSN=TEST'#0 +
'Driver=ODBCJT32.DLL'#0 +
'DBQ=C:\Test.mdb'#0 +
'DefaultDir=C:\Test + #0 +
'Description=Test database'#0 +
'FIL=MS Access'#0 +
'UID=Admin'#0));
end;

procedure RemoveDSN;
begin
SQLConfigDataSource(0, ODBC_REMOVE_DSN,
'Microsoft Access Driver (*.mdb)', PChar(
'DSN=TEST'#0));
end;

--
-Brion
Team JEDI, 2001 Spirit of Delphi Award Winners
http://www.delphi-jedi.org
Fresno Area Delphi Users Group
http://groups.yahoo.com/group/FresnoDelphi


0 new messages