1 Intraweb运用全局变量
一般放在TUSerSession中就可以。
2 这样做应该是有问题的
//------------------------------------------------
//初始化ADOCONNECT对象
//------------------------------------------------
function GetParam(const Param,FileName: String):String;
var
ls: TStringList;
m,i,p:Integer;
Sel:String;
begin
ls:=TStringList.Create;
ls.LoadFromFile(FileName);
m:=ls.Count-1;
for i:=0 to m do
begin
p:=Pos(Param,ls.Strings);
if p>0 then begin
p:=p+6; Sel:=ls.Strings;
Result:=RightStr(Sel,length(Sel)-p);
exit;
end;
end;
ls.Free;
end;
//------------------------------------------------
//初始化ADOCONNECT对象
//------------------------------------------------
procedure InitConn(ADOC: TADOConnection);
var
ConnString,Server,DbName: String;
begin
Server:=GetParam('SERVER=','./files/HYLQ.INI');
DbName:=GetParam('DBNAME=','./files/HYLQ.INI');
ConnString:='Provider=SQLOLEDB.1;Integrated Security=SSPI;';
ConnString:=ConnString+'Persist Security Info=False;';
ConnString:=ConnString+'Initial Catalog='+DBNAME+';';
ConnString:=ConnString+'Data Source='+SERVER+';';
ConnString:=ConnString+'Use Procedure for Prepare=1;';
ConnString:=ConnString+'Auto Translate=True;Packet Size=4096;';
ConnString:=ConnString+'Workstation ID='+SERVER+';';
ConnString:=ConnString+'Use Encryption for Data=False;';
ConnString:=ConnString+'Tag with column collation when possible=False';
ADOC.ConnectionString:=ConnString;
if not ADOC.Connected then ADOC.Connected:=true;
end;