SqlConnection myConn;
SqlCommand myComm;
int result;
private void Button1_Click(object sender, System.EventArgs e)
{
myConn = new SqlConnection("Server=(local);uid=sa;pwd=;database=ShopCar");
myComm = new SqlCommand("select * from Users where cUserName=@name and cPassword=@pass",myConn);
myComm.Parameters.Add("@name",SqlDbType.NChar,20);
myComm.Parameters.Add("@pass",SqlDbType.NChar,20);
myComm.Parameters["@name"].Value = TextBox1.Text.Trim();
myComm.Parameters["@pass"].Value = TextBox2.Text.Trim();
try
{
myComm.Connection.Open();
result = myComm.ExecuteNonQuery();
myComm.Connection.Close();
}
catch (Exception ex)
{
Label3.Text = "连接数据库失败" + ex.Message.ToString();
}
if(result > 0)
{
Response.Redirect("wfProduct.aspx");
}
else
{
Label3.Text = "登录失败,请核对用户名和密码!";
}
}
----------------------------------------------------------------------------------
问题:
result = myComm.ExecuteNonQuery();
怎么用select 不能返回影响的行result ????
我用insert 语句代替里面这个SQL语句,,又能!
指教!!