asp.net登录数据库

编程入门 行业动态 更新时间:2024-10-25 06:22:23
本文介绍了asp登录数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好,我在尝试让我的网站登录时遇到问题。我希望它在登录时显示适当的消息,但始终显示相同的消息电子邮件不正确 能够帮助我吗?

Hi im having a problem when trying to get my website to log in. I want it to display the appropriate message when I log in but I keep getting the same message "Email is not correct " Would anyone be able to help me this ?

protected void loginbutton_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RegConnectionString"].ConnectionString); con.Open(); string checkuser = "select count(*) from Users where email =' " + loginemail.Text + "'"; SqlCommand com = new SqlCommand(checkuser, con); int temp = Convert.ToInt32(com.ExecuteScalar().ToString()); con.Close(); if (temp == 1) { con.Open(); string checkPasswordQuery = "select password from Users where email = '" + loginemail.Text + "'"; SqlCommand pass = new SqlCommand(checkPasswordQuery, con); string password = pass.ExecuteScalar().ToString(); if (password == loginpassword.Text) { Session["New"] = loginemail.Text; Response.Write("Password is Correct"); Response.Redirect("Admin.aspx"); } else { Response.Write("Password is not correct"); } } else { Response.Write("Email is not Correct"); } }

推荐答案

您的电子邮件旁边有一个空格:

There is an space next to your email:

where email =' " + log...

要突出显示它:

where email ='[here there is an empty space] " + log...

我认为这是需要更改的地方:

I think this is what needs to change:

string checkuser = "select count(*) from Users where email ='" + loginemail.Text + "'";

更多推荐

asp.net登录数据库

本文发布于:2023-11-05 04:50:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1559947.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据库   asp   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!