if (conn.State == ConnectionState.Open)
conn.Close();
int l;
bool login=false;;
conn.Open();
SqlCommand cmd = new SqlCommand("login", conn);
= CommandType.StoredProcedure;
cmd.Parameters.Add("@userid", SqlDbType.VarChar, 50);
cmd.Parameters.Add("@passwd", SqlDbType.VarChar, 50);
cmd.Parameters["@userid"].Value = Convert.ToString(textBox_id.Text);
cmd.Parameters["@passwd"].Value = Convert.ToString(textBox_pas.Text);
cmd.Parameters.Add("@out", SqlDbType.Int);
cmd.Parameters["@out"].Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
l=Convert.ToInt16(cmd.Parameters["@out"].Value);
if (l != 0)
{
login = true;
this.Close();
}
else
{
login = false;
MessageBox.Show("用户名密码错误", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}