Jump to content
uniGUI Discussion Forums
Sign in to follow this  
andersonrsbezerra

Conectar banco de dados por um arquivo ini

Recommended Posts

The file name is the application name plus ".ini", and its content is something like..

...

[database]

connectionString=SQLOLEDB.1;User ID=sa;Initial Catalog="database";Data Source=127.0.0.1,1433;Password=blahblehblih

 

 

 

Then i do something like this...

 

...

interface

...

type
  TUniMainModule = class(TUniGUIMainModule)
    ADOConn: TADOConnection;
    procedure UniGUIMainModuleCreate(Sender: TObject);

    ...
  end;

Implementation

...

Uses IniFiles, ...;

...

procedure TUniMainModule.UniGUIMainModuleCreate(Sender: TObject);
begin
    with TMemIniFile.Create(changeFileExt( paramStr(0) , '.conf' )) do begin
        AdoConn.close;
        AdoConn.connectionString    := ReadString('database','connectionString','');
        free;
    end;

    try
         ADOConn.open;
    ...

    end;
end;
 

 

Good luck

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×