使用DataAccessLayer& amp;的登录页面的c#代码sqlHelper类 [英] c# code for login page using DataAccessLayer & sqlHelper class
本文介绍了使用DataAccessLayer& amp;的登录页面的c#代码sqlHelper类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我在登录页面上工作..
ni想要使用DataAccessLayer和SQL HELPER检查用户凭据上课,
CAN ANYBODY PLZ HELP,它的v.urgent ... plz ...
MYCODE_LOGIN_PAGE
Hi Guys,
i'm working on login page..
n i want to check the user credentials using DataAccessLayer and SQL HELPER Class,
CAN ANYBODY PLZ HELP, its v.urgent...plz...
MYCODE_LOGIN_PAGE
protected void btnsignin_Click(object sender, EventArgs e)
{
if (txtuser_login.Text != string.Empty && txt_pwd.Text != string.Empty)
{
try
{
string login_name = txtuser_login.Text;
string login_pwd = txt_pwd.Text;
SqlParameter[] parameters ={
new SqlParameter("@u_name", SqlDbType.VarChar, 50) { Value = login_name },
new SqlParameter("@email", SqlDbType.VarChar, 50) { Value = login_name },
new SqlParameter("@phone", SqlDbType.VarChar, 50) { Value = login_name },
new SqlParameter("@pwd", SqlDbType.Int) { Value = login_pwd }
};
DAL.login_user("sp_login", parameters);
}
catch (Exception ee)
{
}
}
else
{
Response.Write("invalid user/password");
}
}
DATA_ACCESS_LAYER CODE >
public static void login_user(string spname, SqlParameter[] sql_params)
{
SqlConnection conn = new SqlConnection(ConnectionString());
SqlDataReader sdr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, spname, sql_params);
if (sdr.HasRows)
{
}
}
这里的问题是,我如何重定向内容页
谢谢&最诚挚的问候,
ABDUL SUBHAN
HERE THE PROBLEM IS, HOW SHOULD I REDIRECT TO THE CONTENT PAGE
Thanks & Best Regards,
ABDUL SUBHAN
推荐答案
修改DAL方法,如下所示。
Modify DAL method like below.
public static bool login_user(string spname, SqlParameter[] sql_params)
{
bool status = false;
SqlConnection conn = new SqlConnection(ConnectionString());
SqlDataReader sdr = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, spname, sql_params);
if (sdr.HasRows)
{
status = true;
}
return status;
}
修改后面的来电代码。
Modify the caller code like below.
If(DAL.login_user("sp_login", parameters))
{
Response.Redirect("ContentPagePath.aspx");
}
更改一些代码
Change some code
if(DAL.login_user("sp_login", parameters)>0)
{
Response.Redirect("Path of the Page");
并且还要更改数据中的一些访问权限图层
And also change some in your data Access Layer
public static int login_user(string spname, SqlParameter[] sql_params)
{
SqlConnection conn = new SqlConnection(ConnectionString());
return SqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spname, sql_params);
}
I think this code help you. if any query hit the reply.
这篇关于使用DataAccessLayer& amp;的登录页面的c#代码sqlHelper类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文