經營業務接入層:獲取麻煩登錄頁面3 - 輪胎結構
public static int login(string userlogin, string pwdlogin)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = GetConnectionString();
con.Open();
int id = 0;
string selectstr = "SELECT UserName, Password FROM Registration WHERE UserName = '" + userlogin.Trim() + "' AND Password = '" + pwdlogin.Trim() + "'";
SqlCommand cmd = new SqlCommand();
cmd.CommandText = selectstr;
cmd.CommandType = System.Data.CommandType.Text;
cmd.Connection = con;
id = cmd.ExecuteNonQuery();
cmd = null;
con.Close();
return id;
}
Login.cs
protected void Button1_Click(object sender, EventArgs e)
{
int id = BusinessAccessLayer.login(userlogin.Text.Trim(), pwdlogin.Text.Trim());
if (id > 0)
{
message.Text = " valid";
}
else
{
message.Text = "in valid";
}
}
什麼是你的問題? – 2013-03-11 06:58:34
你已經向我們展示了代碼,但沒有告訴我們任何有關錯誤的信息。請閱讀http://tinyurl.com/so-list。 (無可否認,我可以看到四個重要問題,只是瀏覽它,但我不知道這些問題是否與您所看到的有關...) – 2013-03-11 06:58:48
每次顯示無效用戶 – yash 2013-03-11 06:59:34