原来不关连接的事,是我搞错了,原来是我的服务器程序中的数据模块上有一个自定义的方法,当一调用时就出错,说无效索引,开始因为我连接服务器和调用这个方法放在一起,所以以为是连接出错了,我服务器程序的这个方法是如下:是想取得数据库中的表名的 procedure TDM.GetAllTables(var vTables: OleVariant); var tblList:TStringlist; iCount:Integer; begin try tblList:=TStringlist.Create; ADOConnection1.GetTableNames(tblList); vTables:=VarArrayCreate([0,tblList.Count-1],varVariant); for iCount:=0 to tblList.Count-1 do begin vTables[iCount]:=tblList.Strings[iCount]; end; finally tblList.Free; end; end;
procedure TDM.GetAllTables(var vTables: OleVariant);
var
tblList:TStringlist;
iCount:Integer;
begin
try
tblList:=TStringlist.Create;
ADOConnection1.GetTableNames(tblList);
vTables:=VarArrayCreate([0,tblList.Count-1],varVariant);
for iCount:=0 to tblList.Count-1 do
begin
vTables[iCount]:=tblList.Strings[iCount];
end;
finally
tblList.Free;
end;
end;