0

Dear All,

I am having a login page where I need to enter the login name and password for a user, which I need to verify with the backend database, using LINQ.

I have tried but I am not getting.

Can anybody assist.

Following is the underlying code.

protected void Button1_Click(object sender, EventArgs e)    {        QuizUserDetailsDataContext context = new QuizUserDetailsDataContext(ConfigurationManager.ConnectionStrings["krs_projectConnectionString"].ToString());        
krs_userinfo k = new krs_userinfo();        
//if(TextBox1.Text.Equals(k.uname.ToString()))       
 if(TextBox1.Text.Equals(k.uname) && (TextBox2.Text.Equals(k.password)))            Response.Redirect("~/Quizaspx.aspx");    }

This is not working, but not giving any error also.

Many Thanks in Advance.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by rohand
0

You need to write Linq to SQL query to verift login name and password against backend database. I assume krs_userinfo is kind of table where you want to verify your login name and password. What you have done is you are directly checking your textbox value with properties/field name of krs_userinfo. Instead you need to write query in below ways :

var queryKRSUI = From KRSUI in context.krs_userinfo
                 Where KRSUI.uname == textbox1.text.trim()
                 && KRSUI.password == textbox2.text.trim()
                 Select KRSUI;
if(queryKRSUI.Any())
    Response.Redirect("~/Quizaspx.aspx");    
else
    "Invalid LoginName/Password.";

Try by this and let us know...

Dear All,

I am having a login page where I need to enter the login name and password for a user, which I need to verify with the backend database, using LINQ.

I have tried but I am not getting.

Can anybody assist.

Following is the underlying code.

protected void Button1_Click(object sender, EventArgs e)    {        QuizUserDetailsDataContext context = new QuizUserDetailsDataContext(ConfigurationManager.ConnectionStrings["krs_projectConnectionString"].ToString());        
krs_userinfo k = new krs_userinfo();        
//if(TextBox1.Text.Equals(k.uname.ToString()))       
 if(TextBox1.Text.Equals(k.uname) && (TextBox2.Text.Equals(k.password)))            Response.Redirect("~/Quizaspx.aspx");    }

This is not working, but not giving any error also.

Many Thanks in Advance.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.