Interbase configurar SQLConnection
como configuro?
no ConnectionName não aparece o meu banco... como faço?
no ConnectionName não aparece o meu banco... como faço?
Mrcdlf
Curtidas 0
Respostas
Rafaelhelm
17/05/2003
Prezado segue abaixo um exemplo de conexão via arquivo .ini
conteudo do arquivo ini:
[SQLConnection]
ConnectionName=´COSIMA´
DriverName=´Interbase´
GetDriverFunc=´getSQLDriverINTERBASE´
LibraryName=´dbexpint.dll´
VendorLib=´GDS32.DLL´
[Parametros]
BlobSize=´BlobSize=-1´
CommitRetain=´CommitRetain=False´
Database=´Database=C:\Helm\borland\Projetos\Cosima\Banco\Cosima.gdb´
DriverName=´DriverName=Interbase´
ErrorResourceFile=´ErrorResourceFile=´
LocaleCode=´LocaleCode=0000´
Password=´Password=masterkey´
RoleName=´RoleName=RoleName´
ServerCharSet=´ServerCharSet=´
SQLDialect=´SQLDialect=3´
Interbase TransIsolation=´Interbase TransIsolation=ReadCommited´
User_Name=´User_Name=sysdba´
WaitOnLocks=´WaitOnLocks=True´
Codigo do evento onCreate do datamodule onde se encontra o sqlConnection:
procedure TDatamodule.DataModuleCreate(Sender: TObject);
var
ArqIni: TIniFile;
begin
ArqIni:=TIniFile.Create(´.\Banco.ini´);
DM.SQLConnection.Close;
DM.SQLConnection.ConnectionName:=ArqIni.ReadString(´SQLConnection´, ´ConnectionName´, ´´);
DM.SQLConnection.DriverName:=ArqIni.ReadString(´SQLConnection´, ´DriverName´, ´´);
DM.SQLConnection.GetDriverFunc:=ArqIni.ReadString(´SQLConnection´, ´GetDriverFunc´, ´´);
DM.SQLConnection.LibraryName:=ArqIni.ReadString(´SQLConnection´, ´LibraryName´, ´´);
DM.SQLConnection.VendorLib:=ArqIni.ReadString(´SQLConnection´, ´VendorLib´, ´´);
DM.SQLConnection.Params.Clear;
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´BlobSize´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´CommitRetain´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´DataBase´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´DriverName´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´ErrorResourceFile´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´LocaleCode´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´Password´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´RoleName´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´ServerCharSet´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´SQLDialect´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´Interbase TransIsolation´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´User_Name´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´WaitOnLocks´, ´´));
DM.SQLConnection.Connected:=True;
end;
Espero ter ajudado.
conteudo do arquivo ini:
[SQLConnection]
ConnectionName=´COSIMA´
DriverName=´Interbase´
GetDriverFunc=´getSQLDriverINTERBASE´
LibraryName=´dbexpint.dll´
VendorLib=´GDS32.DLL´
[Parametros]
BlobSize=´BlobSize=-1´
CommitRetain=´CommitRetain=False´
Database=´Database=C:\Helm\borland\Projetos\Cosima\Banco\Cosima.gdb´
DriverName=´DriverName=Interbase´
ErrorResourceFile=´ErrorResourceFile=´
LocaleCode=´LocaleCode=0000´
Password=´Password=masterkey´
RoleName=´RoleName=RoleName´
ServerCharSet=´ServerCharSet=´
SQLDialect=´SQLDialect=3´
Interbase TransIsolation=´Interbase TransIsolation=ReadCommited´
User_Name=´User_Name=sysdba´
WaitOnLocks=´WaitOnLocks=True´
Codigo do evento onCreate do datamodule onde se encontra o sqlConnection:
procedure TDatamodule.DataModuleCreate(Sender: TObject);
var
ArqIni: TIniFile;
begin
ArqIni:=TIniFile.Create(´.\Banco.ini´);
DM.SQLConnection.Close;
DM.SQLConnection.ConnectionName:=ArqIni.ReadString(´SQLConnection´, ´ConnectionName´, ´´);
DM.SQLConnection.DriverName:=ArqIni.ReadString(´SQLConnection´, ´DriverName´, ´´);
DM.SQLConnection.GetDriverFunc:=ArqIni.ReadString(´SQLConnection´, ´GetDriverFunc´, ´´);
DM.SQLConnection.LibraryName:=ArqIni.ReadString(´SQLConnection´, ´LibraryName´, ´´);
DM.SQLConnection.VendorLib:=ArqIni.ReadString(´SQLConnection´, ´VendorLib´, ´´);
DM.SQLConnection.Params.Clear;
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´BlobSize´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´CommitRetain´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´DataBase´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´DriverName´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´ErrorResourceFile´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´LocaleCode´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´Password´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´RoleName´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´ServerCharSet´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´SQLDialect´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´Interbase TransIsolation´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´User_Name´, ´´));
DM.SQLConnection.Params.Add(ArqIni.ReadString(´Parametros´, ´WaitOnLocks´, ´´));
DM.SQLConnection.Connected:=True;
end;
Espero ter ajudado.
GOSTEI 0
Obubiba
17/05/2003
Dá pra encurtar bastante o serviço utilizando o comando:
SQLConnection.LoadParamsFromIniFile(´.\Banco.ini´);
SQLConnection.LoadParamsFromIniFile(´.\Banco.ini´);
GOSTEI 0