Connect to the database

xiaoxiao2021-03-05  24

VAR Optionini: Tinifile;

function TDM_Frm.optionSet (conn: TAdoConnection; Param: string): boolean; var serverName, UserName, pwd, DBName: string; begin result: = True; try serverName: = OptionIni.ReadString ( 'SOFT', 'ServerName', ' '); Username: = optionini.readstring (' Soft ',' username ','); PWD: = Optionini.ReadString ('Soft', 'Password', '); DBNAME: = Optionini.Readstring (' Soft ',' Dbname ',' '); if Conn.Connected the Conn.Connected: = FALSE

Conn.connectionstring: = 'provider = SQLOLEDB.1; PERSIST security info = false; user ID =' username '; password =' ​​ pwd '; Initial Catalog =' DBNAME;

IF servername <> '' Then Conn.connectionstring: = conn.connectionstring '; Data Source =' ServerName;

CONN.CONNECTIONSTRING: = conn.connectionstring '; use procedure for prepare = 1; auto translate = true; packet size = 4096';

Conn.connected: = true; Except ServerName: = Optionini.ReadString ('Soft', 'ServerName', ''); username: = Optionini.ReadString ('Soft', 'Username', '); PWD: = Optionini .Readstring ('Soft', 'Password', '); DBName: = Optionini.ReadString (' Soft ',' DBNAME ',' '); if Conn.Connected the Conn.Connected: = FALSE

conn.ConnectionString: = 'Provider = SQLOLEDB.1; Persist Security Info = False; User ID =' UserName '; password =' ​​ pwd '; Initial Catalog =' DBName FormatDateTime ( 'YYYY', now) ; if Servername <> '' Then Conn.connectionstring: = conn.connectionstring '; Data Source =' ServerName;

CONN.CONNECTIONSTRING: = conn.connectionstring '; use procedure for prepare = 1; auto translate = true; packet size = 4096';

CONN.CONNECTED: = TRUE;

RESULT: = false; end;

Procedure TDM_FRM.DATAMODULECREATE (Sender: Tobject); begin apppath: = getApplicationPath; Optionini: = TiniFile.create (AppPath 'config.ini'); optionSet (Adoconn);

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

New Post(0)