刪除:其中'CostingDB'為數據庫別名 
    Session.DeleteAlias('CostingDB');
     Session.SaveConfigFile;
如還有問題  QQ :112925366另外還有一種判斷的方法,以下為一個實例:
Procedure TBasDM.LoginServer;
var tempIni: TIniFile;
tmpServerFrm: TServerFrm;
                i:Integer;
                tmpList:TStringList;
                IsAliasName:Boolean;
begin  IsAliasName:=false;
tmpList:= TStringList.Create;
try
   Session.GetAliasNames(tmpList);
  for I := 0 to tmpList.Count - 1 do
      if tmpList[i]='CostingDB' then
IsAliasName:=true;    if not IsAliasName then
   Session.AddAlias('CostingDB','MSSQL',CostDB.Params);
finally
   tmpList.Free;
end;   ......end;

解决方案 »

  1.   

    当你用BDE的DataBase控件连接数据库时,属性Alias一栏可通过下拉框选择ODBC或BDE中已设置好的数据库别名(这是真实的数据库别名),如DB1;属性DataBaseName一栏为你自己输入的另一个别名(虚拟的数据库别名)如MyDB,用来提供给别的数据库控件,如Table, Query共享DataBase控件的连接。当这些控件连接数据库时最好都选用别名MyDB,这样可以由一个DataBase控件来统一管理数据库的连接,也不会出现别名不唯一的提示。打开Delphi自带的SQL Explorer你会看到DB1,MyDB都在,其中MyDB是虚拟的;但对其中任何一个的操作都会使另一个同步变化。