Delphi Read Database Link Ini File

xiaoxiao2021-03-06  69

Unit undm;

Interface

Uses sysutils, classes, db, adoDB;

type TDM_Tax = class (TDataModule) ADOCon_Tax: TADOConnection; ADOQry_Tax: TADOQuery; procedure DataModuleCreate (Sender: TObject); private {Private declarations} public {Public declarations} end;

VAR DM_TAX: TDM_TAX;

ImplementationUses inIfiles, UN_TAXMAIN

{$ R * .dfm}

procedure TDM_Tax.DataModuleCreate (Sender: TObject); var ConnStr, provider, password, userid, datasource, initcatalog: String; inifilename: String; inifile: TInifile; begin inifilename: = ExtractFilePath (paramstr (0)) 'db.ini' Inifile: = Tinifile.create (InIfileName); Provider: = INIFILE.ReadString ('Database', 'Provider', 'Sqloledb.1'); UserId: = INIFILE.Readstring ('Database', 'User ID ",' SA '); Password: = INIFILE.ReadString (' Database ',' Password ',' sa '); DataSource: = INIFILE.ReadString (' Database ',' Data Source ',' 127.0.0.1 '); INTCATALOG: = inifile.ReadString ( 'Database', 'Initial Catalog', 'tax'); ConnStr: = 'Provider =' provider '; password =' ​​ password '; Persist Security Info = True; User ID =' userid '; Data Source = ' DataSource '; Initial Catalog = ' INITCATALOG; InIfile.destroy; adocon_tax.connectionstring: = connStr; try adocon_tax.connected; end;

End.

转载请注明原文地址:https://www.9cbs.com/read-109635.html

New Post(0)