判断SQL SERVER 服务是否断开

unit DTDem;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Psock, NMDayTim, ExtCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Edit1: TEdit;
    Edit2: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    NMDayTime1: TNMDayTime;
    Button1: TButton;
    Label3: TLabel;
    StatusBar1: TStatusBar;
    procedure Button1Click(Sender: TObject);
    procedure NMDayTime1Connect(Sender: TObject);
    procedure NMDayTime1Disconnect(Sender: TObject);
    procedure NMDayTime1HostResolved(Sender: TComponent);
    procedure NMDayTime1Status(Sender: TComponent; Status: String);
    procedure NMDayTime1ConnectionFailed(Sender: TObject);
    procedure NMDayTime1InvalidHost(var handled: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

const
  StdCap = 'The Current Date and Time is : ';

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  NMDayTime1.ReportLevel := Status_Basic;  //控制数量,Status_Basic=2。
  NMDayTime1.TimeOut := 300;  //控制时间,以毫秒为单位。
  NMDayTime1.Host := Edit1.Text;  //主机的名称或远程主机的IP地址。
  NMDayTime1.Port := StrToInt(Edit2.Text); //主机的端口。
  Label3.Caption := StdCap+NMDayTime1.DayTimeStr;//显示时间。
end;
//连接远程主机,此事件发生。
procedure TForm1.NMDayTime1Connect(Sender: TObject);
begin
  StatusBar1.SimpleText := 'Connected';     //显示连接
end;
//和远程的主机没连接上,此事件发生。
procedure TForm1.NMDayTime1Disconnect(Sender: TObject);
begin
  If StatusBar1 <> nil then
    StatusBar1.SimpleText := 'disconnected'; //显示断开连接。
end;
//当远程的主机地址被断然拒绝,此事件发生。
procedure TForm1.NMDayTime1HostResolved(Sender: TComponent);
begin
  StatusBar1.SimpleText := 'Host resolved';
end;
//一些状态改变时,此事件发生。
procedure TForm1.NMDayTime1Status(Sender: TComponent; Status: String);
begin
  If StatusBar1 <> nil then
    StatusBar1.SimpleText := status;
end;
//连接失败,此事件发生。
procedure TForm1.NMDayTime1ConnectionFailed(Sender: TObject);
begin
  ShowMessage('Connection Failed');
end;
//主机出毛病,此事件发生。
procedure TForm1.NMDayTime1InvalidHost(var handled: Boolean);
var
  TmpStr: String;
begin
  If InputQuery('Invalid Host!', 'Specify a new host:', TmpStr) then
  Begin
    NMDayTime1.Host := TmpStr;
    Handled := TRUE;
  End;
end;

end.
要使用TNMDayTime控件。
AdoQquery1.Sort = '字段名称 ASC'

你可能感兴趣的:(SQL Server)