鑫恺瑞 >> 服务支持 >> 数 据 库 >> ADO.NET >> 正文

用ADO连接数据库的简便函数

文章来源:互联网 更新时间:2010-04-09
function ConnectLocalDB(const adocon:TadoConnection;const dbname,computername:string):boolean;
begin
  with adocon do
  begin
    Close;
    LoginPrompt:=false;
    //若数据库不存在时,进行判断。。。。。。
    ConnectionString:='Provider=SQLOLEDB.1;'+
                      'Persist Security Info=False;'+
                      'User ID=sa;Initial Catalog='+dbname+';'+
                      'Data Source='+ComputerName;
    try
      KeepConnection:=true;
      Connected:=true;
      Open;
      ConnectLocalDB:=true;
    except
      ConnectLocalDB:=false;
    end;
  end;
end;

数据载入中,请稍后……
编辑推荐
  • 没有推荐文章