【发布时间】:2013-10-10 01:40:49
【问题描述】:
达尔码
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 u_email=@email and u_pass=@password
【问题讨论】:
-
您可能想提供更多关于您的问题的文本。
-
嗯.. 好代码!代码有问题吗?还是只是为了向我们展示您的代码?
-
看起来你没有表0,也许你应该添加一个?您希望通过在此处发布此代码得到什么?
-
如果没有用户提供的电子邮件和密码会怎样?数据集中没有返回表,因此您不能使用索引为零的表,因为没有表
标签: c# html asp.net ajax sql-server-2008