本帖最后由 赵威 于 2013-4-29 09:04 编辑
SqlConnection con = null;
try
{
string s = "server=hp-85235e878f32.;uid=sa;pwd=;database=qimozuoye";
//SqlConnection
con = new SqlConnection(s);
con.Open();
string ss = "select * from Sheet1$ where user_id='" + textBox1.Text + "' and user_mima='" + textBox2.Text + "'";
SqlCommand cmd = new SqlCommand(ss, con);
int i = cmd.ExecuteNonQuery();//在
if (textBox1.Text == " " || textBox2.Text == "")
{
MessageBox.Show("用户名或密码不能为空", "错误");
return;
} if (i==1)
//SqlDataReader dr = cmd.ExecuteReader();
//if (dr.Read())
{
MessageBox.Show("登录成功!");
Form4 f = new Form4();
f.Show();
}
else
{
MessageBox.Show("用户名或密码有错误!");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
con.Close();
{
}
}
在登录的时候,输入了正确的用户名和密码,可是为什么还是提示用户名密码错误????
|