如果程序刚刚运行,SQL SERVICE 未连接,如果在程序中得知,并给用户提示。
用的组件是ADO组件。请教高手。

解决方案 »

  1.   

    你可以自己生成Ado 连接字符串,由客户给出密码,等
      

  2.   

    procedure TForm1.FormCreate(Sender: TObject);
    begin
         adoCoon.ConnectionString :='Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data Source=10.26.127.222' ;
         if adoCoon.connected =false then
         begin
            showMessage('false')
         end
    //下面可以用来判断数据库是否可以正确连接,上面只是判断数据库是否处于连接状态,但并检
    //查数据库连接是否正确
         {try
             adoCoon.Connected := true;
             Showmessage('true');
         except
             ShowMessage('false');
         end;}
    end;