我给你一段代码:
在服务器段:定义一个接口的函数Changedb
procedure Tsqlserver.ChangeDB(var dbname: OleVariant);
begin
ADOConnection1.Connected:=FALSE;
ADOConnection1.ConnectionString:=
'Provider=SQLOLEDB.1'+';'+'Persist Security Info=False'
+';'+'User ID=sa;Initial Catalog='
+dbname+';'+'Data Source=ZHF'+';'+'Use Procedure for Prepare=1'
+';'+'Auto Translate=True'+';'+'Packet Size=4096'+';'+'Workstation ID=ZHF'+';'+
ADOConnection1.Connected:=True'+';';
ADOConnection1.connected:=True;
end;
然后,在客户端调用即可.