Re: trouble creating DSN
- From: "Keith G Hicks" <krh@xxxxxxxxxxx>
- Date: Sat, 18 Nov 2006 12:31:44 -0500
So I decided to just wirte to the registry. It's easier. Here's what I did
in case anyone else needs the info:
procedure TForm1.Button1Click(Sender: TObject);
var
Reg: TRegistry;
begin
Reg := TRegistry.Create;
try
with Reg do
begin
RootKey := HKEY_LOCAL_MACHINE;
OpenKey('Software\ODBC\ODBC.INI\Keiths Test DSN', True);
WriteString('Database', 'Northwind');
WriteString('Description', 'Keiths Test DSN description');
WriteString('Driver', 'C:\WINNT\system32\SQLSRV32.dll');
WriteString('Server', 'myserver');
WriteString('LastUser', 'sa');
CloseKey;
end;
(* Open ODBC Data Sources key to list the new DSN in the ODBC Manager.
Specify the new value. Close the key. *)
with Reg do
begin
RootKey := HKEY_LOCAL_MACHINE;
OpenKey('SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources', false); // do not
allow create in this case since it should already exist?
WriteString('Keiths Test DSN', 'SQL Server');
CloseKey;
end;
finally
Reg.Free;
end;
end;
.
- References:
- trouble creating DSN
- From: Keith G Hicks
- Re: trouble creating DSN
- From: Keith G Hicks
- trouble creating DSN
- Prev by Date: Re: trouble creating DSN
- Next by Date: Re: Transaction Problem, part two..
- Previous by thread: Re: trouble creating DSN
- Index(es):