5 个解决方案
#1
用 ModifyAlias
or example, the following statements use ModifyAlias to change the OPEN MODE parameter for the CATS alias to READ/WRITE in the default session:
var
List: TStringList;
begin
List := TStringList.Create;
with List do begin
Clear;
Add('OPEN MODE=READ/WRITE');
end;
Session.ModifyAlias('CATS', List);
List.Free;
...
or example, the following statements use ModifyAlias to change the OPEN MODE parameter for the CATS alias to READ/WRITE in the default session:
var
List: TStringList;
begin
List := TStringList.Create;
with List do begin
Clear;
Add('OPEN MODE=READ/WRITE');
end;
Session.ModifyAlias('CATS', List);
List.Free;
...
#2
修改tdatabase的Params属性,如:
Params.add("DATABASE NAME=XXX")
Params.add("DATABASE NAME=XXX")
#3
先可以將DATABASE的設置在server.ini中。
procedure TData1.DataModuleCreate(Sender: TObject);
var v_path,v_data_name,v_server_name,v_user_name,v_pass:string;
myini:tinifile;
begin
data1.Connected:=false;
data1.Params.Clear;
v_path:=extractfiledir(application.exename)+'\server.ini';
try
myini:=TInifile.Create(v_path);
v_data_name:=myini.ReadString('server','database name','wxzx');
v_server_name:=myini.ReadString('server','server_name','bbs');
v_user_name:=myini.ReadString('server','user_name','sa');
v_pass:=myini.ReadString('server','password','');
myini.Destroy;
except
begin
showmessage('INI文件不存在');
halt;
end;
end;
data1.Params.clear;
data1.Params.Add('database name='+v_data_name+'');
data1.Params.Add('server name='+v_server_name+'');
data1.Params.Add('user name='+v_user_name+'');
data1.Params.Add('password='+v_pass+'');
data1.Connected:=true;
end;
procedure TData1.DataModuleCreate(Sender: TObject);
var v_path,v_data_name,v_server_name,v_user_name,v_pass:string;
myini:tinifile;
begin
data1.Connected:=false;
data1.Params.Clear;
v_path:=extractfiledir(application.exename)+'\server.ini';
try
myini:=TInifile.Create(v_path);
v_data_name:=myini.ReadString('server','database name','wxzx');
v_server_name:=myini.ReadString('server','server_name','bbs');
v_user_name:=myini.ReadString('server','user_name','sa');
v_pass:=myini.ReadString('server','password','');
myini.Destroy;
except
begin
showmessage('INI文件不存在');
halt;
end;
end;
data1.Params.clear;
data1.Params.Add('database name='+v_data_name+'');
data1.Params.Add('server name='+v_server_name+'');
data1.Params.Add('user name='+v_user_name+'');
data1.Params.Add('password='+v_pass+'');
data1.Connected:=true;
end;
#4
方法很多哦,上面已经提出n种了
#5
谢谢大家
#1
用 ModifyAlias
or example, the following statements use ModifyAlias to change the OPEN MODE parameter for the CATS alias to READ/WRITE in the default session:
var
List: TStringList;
begin
List := TStringList.Create;
with List do begin
Clear;
Add('OPEN MODE=READ/WRITE');
end;
Session.ModifyAlias('CATS', List);
List.Free;
...
or example, the following statements use ModifyAlias to change the OPEN MODE parameter for the CATS alias to READ/WRITE in the default session:
var
List: TStringList;
begin
List := TStringList.Create;
with List do begin
Clear;
Add('OPEN MODE=READ/WRITE');
end;
Session.ModifyAlias('CATS', List);
List.Free;
...
#2
修改tdatabase的Params属性,如:
Params.add("DATABASE NAME=XXX")
Params.add("DATABASE NAME=XXX")
#3
先可以將DATABASE的設置在server.ini中。
procedure TData1.DataModuleCreate(Sender: TObject);
var v_path,v_data_name,v_server_name,v_user_name,v_pass:string;
myini:tinifile;
begin
data1.Connected:=false;
data1.Params.Clear;
v_path:=extractfiledir(application.exename)+'\server.ini';
try
myini:=TInifile.Create(v_path);
v_data_name:=myini.ReadString('server','database name','wxzx');
v_server_name:=myini.ReadString('server','server_name','bbs');
v_user_name:=myini.ReadString('server','user_name','sa');
v_pass:=myini.ReadString('server','password','');
myini.Destroy;
except
begin
showmessage('INI文件不存在');
halt;
end;
end;
data1.Params.clear;
data1.Params.Add('database name='+v_data_name+'');
data1.Params.Add('server name='+v_server_name+'');
data1.Params.Add('user name='+v_user_name+'');
data1.Params.Add('password='+v_pass+'');
data1.Connected:=true;
end;
procedure TData1.DataModuleCreate(Sender: TObject);
var v_path,v_data_name,v_server_name,v_user_name,v_pass:string;
myini:tinifile;
begin
data1.Connected:=false;
data1.Params.Clear;
v_path:=extractfiledir(application.exename)+'\server.ini';
try
myini:=TInifile.Create(v_path);
v_data_name:=myini.ReadString('server','database name','wxzx');
v_server_name:=myini.ReadString('server','server_name','bbs');
v_user_name:=myini.ReadString('server','user_name','sa');
v_pass:=myini.ReadString('server','password','');
myini.Destroy;
except
begin
showmessage('INI文件不存在');
halt;
end;
end;
data1.Params.clear;
data1.Params.Add('database name='+v_data_name+'');
data1.Params.Add('server name='+v_server_name+'');
data1.Params.Add('user name='+v_user_name+'');
data1.Params.Add('password='+v_pass+'');
data1.Connected:=true;
end;
#4
方法很多哦,上面已经提出n种了
#5
谢谢大家