Board index » delphi » Creating system DSN's

Creating system DSN's

Is there a way to programmatically create a system DSN?

TIA

 

Re:Creating system DSN's


Quote
>Is there a way to programmatically create a system DSN?

You can use functions in odbccp32.dl example follows
But its probably easier to just create the registry entries that make up a DSN

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;

implementation

Function  SQLConfigDataSource;external 'odbccp32.dll' name
'SQLConfigDataSource';

end.

Call the function like this:

Var
Attr:String;

Begin
Attr:='Description=TimeClient DSN;Server=PRAMIS.PRA';
SqlConfigDataSource(Handle,ODBC_ADD_SYS_SDN,Pchar('Oracle73'),pchar(Attr));
End;

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Creating system DSN's


"Brian Bushay TeamB" <BBus...@Nmpls.com> wrote in message
news:vv44ut8usd5dor2mgamgdth8ado8q2p9vb@4ax.com...

Quote

> >Is there a way to programmatically create a system DSN?

> You can use functions in odbccp32.dl example follows
> But its probably easier to just create the registry entries that make up a DSN

Hardly.  This way you can check for the driver, or most recent version,  Verify that it is
correctly installed, and then create the DSN.

Other Threads