using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Linq;
using System.Data.SqlClient;
namespace StopSQLServer
{
public partial class Frm_Main : Form
{
public Frm_Main()
{
InitializeComponent();
}
void the button1_Click Private (SENDER Object, EventArgs E)
{
the using (the SqlConnection the SqlConnection new new = CON (// create a database connection object br /> @ "= LVSHUANG Server \ SHJ; pwd =; UID = SA; Master Database ="))
{
the try
{
string strShutdown = "the WITH the NOWAIT the SHUTDOWN"; // Create the SQL string
SqlCommand cmd = new SqlCommand (); // Create command object
cmd.Connection = con; // set the connection properties
cmd.Connection.Open (); / / open database Connectivity
cmd.CommandText = strShutdown; SQL statements // set to be executed
cmd.ExecuteNonQuery (); // execute the SQL statement
MessageBox.Show ( "service has been successfully disconnected"); // message Boxes
}
The catch (Exception Euy)
{
MessageBox.Show (euy.Message); // pop-up message box
}
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();//关闭窗体
}
}
}