procedure TfrmDataModule.DataModuleCreate(Sender: TObject);
var
reg: TRegistry;
lfIni: TiniFile;
lsDBName, lsSQLServeIP, lsConnStr, lscpConnStr: string;
begin
lfIni := TiniFile.Create(ExtractFileDir(Application.ExeName) + '\' +WideString('SysParams.ini'));
SHSCon.Close;
lsConnStr := 'Provider=SQLOLEDB.1;'
+ 'Password=' + lfIni.ReadString('option', 'SQLPassword', '')+ ';'
+ 'Persist Security Info=True;'
+ 'User ID=sa;'
+ 'Initial Catalog=' + lfIni.ReadString('option', 'DataBase', '') + ';'
+ 'Data Source=' + lfIni.ReadString('option', 'ServerIP', '');
lsSQLServeIP := lfIni.ReadString('option', 'ServerIP', '');
SHSCon.ConnectionString := lsConnStr;
SHSCon.Open;
///////////////////////////////////
var
reg: TRegistry;
lfIni: TiniFile;
lsDBName, lsSQLServeIP, lsConnStr, lscpConnStr: string;
begin
lfIni := TiniFile.Create(ExtractFileDir(Application.ExeName) + '\' +WideString('SysParams.ini'));
SHSCon.Close;
lsConnStr := 'Provider=SQLOLEDB.1;'
+ 'Password=' + lfIni.ReadString('option', 'SQLPassword', '')+ ';'
+ 'Persist Security Info=True;'
+ 'User ID=sa;'
+ 'Initial Catalog=' + lfIni.ReadString('option', 'DataBase', '') + ';'
+ 'Data Source=' + lfIni.ReadString('option', 'ServerIP', '');
lsSQLServeIP := lfIni.ReadString('option', 'ServerIP', '');
SHSCon.ConnectionString := lsConnStr;
SHSCon.Open;
///////////////////////////////////
end;
本文转自鹅倌51CTO博客,原文链接:http://blog.51cto.com/kaixinbuliao/1401559 ,如需转载请自行联系原作者