请问:
   怎么 判断 已经连上数据库(SQLSERVER 数据库) 如果不上的话我出现我自己的提示。
   
   我想如果连不上服务器的话弹出设置连接服务器的对话框

解决方案 »

  1.   

    connection1.connected = ture 就是连上了
      

  2.   

    function TDm.OpenConn():Boolean;//连接数据库
    begin
      try
        if ADOConnection1.Connected then ADOConnection1.Close;
        ADOConnection1.ConnectionString := LoadIni() ;
        ADOConnection1.Connected := True;
        Result := True;
      except
       begin
        Result := False;
      end;
      end;
    end;
    if Cdm.dm.OpenConn then
      begin
      end
    else
      begin
        ShowMessage('无法连接数据库服务器,请重新配置系统!');
        fmSysSetup:= TfmSysSetup.Create(Application);
        fmSysSetup.Showmodal;
        fmSysSetup.Free;
      end;
    end;
      

  3.   

    在未连接上数据库时可以自动弹出数据库连接对话框。
    implementation
      uses  adoconed;
    {$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
    begin
     if EditConnectionString(adoconnection1)  then
       showmessage(adoconnection1.connectionstring);end;
      

  4.   

    if connection1.connected then
      ShowMessage('已连接!');