各位大侠:
   我想做出这样的功能出来 当我adoquery1 insert 数据库时,如果ADOConnection
没有正确连接数据库 软件自动重新连接数据库,我想知道,我如何知道ADOConnection
是否正确连接数据库 adoconnection.connected 我试过了不行,
谢谢

解决方案 »

  1.   

    procedure TForm1.ConnDb;
    var
      strConn:wideString;
    begin
      try
        adoconn.Connected:=true;
      except
        adoconn.Close;
        strConn:='Provider=Microsoft.Jet.OLEDB.4.0;'
                 +' Data Source=C:\Documents and Settings\Qkhhxkj\桌面\db.mdb;'
                 +'Persist Security Info=False';
        adoconn.ConnectionString:=strConn;
        adoconn.Connected:=true;
        adoq.Connection:=adoconn;
      end;
    end;这样你看看行不行
      

  2.   

    adoconnection.state:=常量;
    常量   说明     
      adStateClosed   默认,指示对象是关闭的。     
      adStateOpen   指示对象是打开的。     
      adStateConnecting   指示   Recordset   对象正在连接。     
      adStateExecuting   指示   Recordset   对象正在执行命令。     
      adStateFetching   指示   Recordset   对象的行正在被读取