![]() |
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.... |
Te recomiendo buscar información en la web sobre la ODBC API SQLConfigDataSource.
Saludos! |
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. |
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; |
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 09:34:07. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi