private void btnOK_Click(object sender, System.EventArgs e)
{
System.Data.SqlClient.SqlConnection conn =new System.Data.SqlClient.SqlConnection ();
conn.ConnectionString ="workstation id='PARADISE-II';packet size=4096;user id=sa;data source='PARADISE-II';persist security info=True;initial catalog=Dispatcher;password=meimima";

try
{
conn.Open();

System.Data.SqlClient.SqlCommand command=conn.CreateCommand();
command.CommandText="select * from User where username='" + txtUser.Text + "'";
System.Data.SqlClient.SqlDataReader dataReader=command.ExecuteReader();/* *****************/
if(dataReader.Read()==false)
MessageBox.Show("用户名密码不正确,请重新输入。","登录失败",MessageBoxButtons.OK,MessageBoxIcon.Information);
else
this.Close();
}
catch (Exception ex)
{
MessageBox.Show("连接数据库错误,请与管理员联系。","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
Application.Exit();
}
finally
{
conn.Close();
}
}