procedure TForm1.FormShow(Sender: TObject);
var
Ls:Tstringlist;
i:integer;
ss,masteruser,sa,dbservername:string;begin Ls:=Tstringlist.Create;
Ls.LoadFromFile(appPath+'property.txt');
for i:=0 to 3 do begin
ss:=ls.Strings[i];
if i=0 then sysdb:=trim(copy(ss,pos('=',ss)+1,100));
if i=1 then masteruser:=trim(copy(ss,pos('=',ss)+1,100));
if i=2 then sa:=trim(copy(ss,pos('=',ss)+1,100));
if i=3 then dbservername:=trim(copy(ss,pos('=',ss)+1,100));
end; if sa<>'' then
sdbconn:='SQLOLEDB.1;Password='+sa+';Persist Security Info=True;User ID='+masteruser+';Initial Catalog='+sysdb+';Data Source='+dbservername
else
sdbconn:='SQLOLEDB.1;Persist Security Info=True;User ID='+masteruser+';Initial Catalog='+sysdb+';Data Source='+dbservername;
ls.Free; ADOConnection1.Close;
ADOConnection1.ConnectionString:=sdbconn;
try
ADOConnection1.Open();
except
showmessage('连接数据库失败');
exit;
end;
end;
var
Ls:Tstringlist;
i:integer;
ss,masteruser,sa,dbservername:string;begin Ls:=Tstringlist.Create;
Ls.LoadFromFile(appPath+'property.txt');
for i:=0 to 3 do begin
ss:=ls.Strings[i];
if i=0 then sysdb:=trim(copy(ss,pos('=',ss)+1,100));
if i=1 then masteruser:=trim(copy(ss,pos('=',ss)+1,100));
if i=2 then sa:=trim(copy(ss,pos('=',ss)+1,100));
if i=3 then dbservername:=trim(copy(ss,pos('=',ss)+1,100));
end; if sa<>'' then
sdbconn:='SQLOLEDB.1;Password='+sa+';Persist Security Info=True;User ID='+masteruser+';Initial Catalog='+sysdb+';Data Source='+dbservername
else
sdbconn:='SQLOLEDB.1;Persist Security Info=True;User ID='+masteruser+';Initial Catalog='+sysdb+';Data Source='+dbservername;
ls.Free; ADOConnection1.Close;
ADOConnection1.ConnectionString:=sdbconn;
try
ADOConnection1.Open();
except
showmessage('连接数据库失败');
exit;
end;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货