德爾代碼System.IndexOutOfRangeException:無法找到表0
public DataSet selectlogin(string u_name, string u_password, string u_email, string action)
{
SqlConnection con = new SqlConnection(h);
SqlCommand cmd = new SqlCommand("", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_login";
cmd.Parameters.AddWithValue("@name", u_name);
cmd.Parameters.AddWithValue("@email", u_email);
cmd.Parameters.AddWithValue("@password", u_password);
cmd.Parameters.AddWithValue("@action", action);
con.Open();
cmd.ExecuteNonQuery();
DataSet ds = new DataSet();
SqlDataAdapter ad = new SqlDataAdapter(cmd);
ad.Fill(ds);
return ds;
con.Close();
}
巴爾代碼
public DataSet selectlogin(string u_name, string u_password, string u_email, string action)
{
DataSet ds = new DataSet();
ds = obj.selectlogin(u_name, u_password, u_email, action);
return ds;
}
CS代碼
protected void Btn_log(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds = obj.selectlogin("", TextBox1.Text, TextBox2.Text,"login");
if (ds.Tables[0].Rows.Count > 0)
{
Response.Redirect("dashboard.aspx");
}
}
存儲過程
if(@action='login')
select * from login where [email protected] and [email protected]
你可能想給更多的文本關於你的問題。 –
嗯..不錯的代碼!代碼有問題嗎?還是僅僅向我們展示你的代碼? –
看起來你沒有桌子0,也許你應該添加一個?你期望在這裏發佈這個代碼什麼? – iabbott