Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Conexión con bases de datos (https://www.clubdelphi.com/foros/forumdisplay.php?f=2)
-   -   Se puede crear un System DSN (ODBC) mediante programacion en delphi? (https://www.clubdelphi.com/foros/showthread.php?t=2890)

VOR 11-08-2003 21:59:09

Se puede crear un System DSN (ODBC) mediante programacion en delphi?
 
Que tal

Necesito crear un system dsn en el ODBC al ejecutar un programa en delphi, no se si se pueda hecer esto mediante programacion en delphi.

de antemano muchas Gracias....

delphi.com.ar 11-08-2003 22:12:05

Te recomiendo buscar información en la web sobre la ODBC API SQLConfigDataSource.

Saludos!

Lmas 13-08-2003 22:22:50

Hola VOR.

...marchando truco del almendruco.

Lo mejor para crearlo es... ¡que le crees tu mismo a mano! :D :D :D :D

.
.
.

:mad: :mad: :mad: :mad:

.
.
.

Vale, vale.

Una vez que hayas creado el DSN, con el RegEdit o editor del registro, ve a la clave HKEY_LOCAL_MACHINE\Software\ODBC\ODBC.INI\ y ahí te aparecerá una clave con toda la información del DSN que hayas creado a mano.

Entonces, tu programa lo único que tendrá que hacer es crear todas esas entradas con sus correspondientes valores.

tamara 05-09-2003 22:23:24

El otro dia lo hize asi y funciono:

Pones Registry en el uses

procedure TForm1.Button1Click(Sender: TObject);
var
R1:TRegistry;
begin
R1:=TRegistry.create;
R1.RootKey := HKEY_LOCAL_MACHINE;
if R1.OpenKey('SOFTWARE\ODBC\ODBC.INI',FALSE)
then R1.CreateKey(nombre.Text);
R1.Destroy;
R1:=TRegistry.create;
R1.RootKey := HKEY_LOCAL_MACHINE;
if R1.OpenKey('SOFTWARE\ODBC\ODBC.INI\'+nombre.Text,FALSE) then
begin
R1.WriteString('DBQ',Path.Text);
R1.WriteString('Driver',PathDll.Text);
R1.WriteInteger('DriverId', 25);
R1.WriteString('FIL','MS Access;');
R1.WriteString('PWD',clave.text);
R1.WriteInteger('SafeTransactions', 0);
R1.WriteString('UID',usr.text);
R1.CreateKey('Engines');
R1.Destroy;
R1:=TRegistry.create;
R1.RootKey := HKEY_LOCAL_MACHINE;
if R1.OpenKey('SOFTWARE\ODBC\ODBC.INI\'+nombre.Text+'\Engines',FALSE) then
begin
R1.CreateKey('Jet');
R1.Destroy;
R1:=TRegistry.create;
R1.RootKey := HKEY_LOCAL_MACHINE;
if R1.OpenKey('SOFTWARE\ODBC\ODBC.INI\'+nombre.Text+'\Engines\Jet',FALSE) then
begin
R1.WriteString('ImplicitCommitSync','');
R1.WriteInteger('MaxBufferSize', 2048);
R1.WriteInteger('PageTimeout', 5);
R1.WriteInteger('Threads', 3);
R1.WriteString('UserCommitSync','Yes');
R1.Destroy;
R1:=TRegistry.create;
R1.RootKey := HKEY_LOCAL_MACHINE;
if R1.OpenKey('SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources',FALSE) then
begin
R1.WriteString(nombre.text, driver2.text);
R1.Destroy;
ShowMessage(' ALIAS CREADO. ');
end;
end;
end;
end;
end;

tamara 05-09-2003 22:24:13

El otro dia lo hize asi y funciono:

Pones Registry en el uses

procedure TForm1.Button1Click(Sender: TObject);
var
R1:TRegistry;
begin
R1:=TRegistry.create;
R1.RootKey := HKEY_LOCAL_MACHINE;
if R1.OpenKey('SOFTWARE\ODBC\ODBC.INI',FALSE)
then R1.CreateKey(nombre.Text);
R1.Destroy;
R1:=TRegistry.create;
R1.RootKey := HKEY_LOCAL_MACHINE;
if R1.OpenKey('SOFTWARE\ODBC\ODBC.INI\'+nombre.Text,FALSE) then
begin
R1.WriteString('DBQ',Path.Text);
R1.WriteString('Driver',PathDll.Text);
R1.WriteInteger('DriverId', 25);
R1.WriteString('FIL','MS Access;');
R1.WriteString('PWD',clave.text);
R1.WriteInteger('SafeTransactions', 0);
R1.WriteString('UID',usr.text);
R1.CreateKey('Engines');
R1.Destroy;
R1:=TRegistry.create;
R1.RootKey := HKEY_LOCAL_MACHINE;
if R1.OpenKey('SOFTWARE\ODBC\ODBC.INI\'+nombre.Text+'\Engines',FALSE) then
begin
R1.CreateKey('Jet');
R1.Destroy;
R1:=TRegistry.create;
R1.RootKey := HKEY_LOCAL_MACHINE;
if R1.OpenKey('SOFTWARE\ODBC\ODBC.INI\'+nombre.Text+'\Engines\Jet',FALSE) then
begin
R1.WriteString('ImplicitCommitSync','');
R1.WriteInteger('MaxBufferSize', 2048);
R1.WriteInteger('PageTimeout', 5);
R1.WriteInteger('Threads', 3);
R1.WriteString('UserCommitSync','Yes');
R1.Destroy;
R1:=TRegistry.create;
R1.RootKey := HKEY_LOCAL_MACHINE;
if R1.OpenKey('SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources',FALSE) then
begin
R1.WriteString(nombre.text, driver2.text);
R1.Destroy;
ShowMessage(' ALIAS CREADO. ');
end;
end;
end;
end;
end;


La franja horaria es GMT +2. Ahora son las 12:34:14.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi