如何从登录页面的后端到前端读取数据库值? [英] How to read database values from backend to front end in login page?

查看:795
本文介绍了如何从登录页面的后端到前端读取数据库值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我也在创建登录页面和注册表单.我在gesture forn中输入了一些值并保存了.现在我想从这些值中登录(用户名和密码).请解决我的问题.

Hi
I''m creating login page and registration form also.I entered some values in regestration forn and saved.now i want to login from those values(user id& password).Please solve my problem.

推荐答案

请参阅参考资料

http://msdn.microsoft.com/en-us/library/haa3afyz (v = vs.80).aspx [ http://msdn.microsoft.com/en-us/library/system. data.sqlclient.sqldatareader.aspx [ ^ ]


see reference

http://msdn.microsoft.com/en-us/library/haa3afyz(v=vs.80).aspx[^]

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.aspx[^]

or
SqlConnection objConnection = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["connectionString"].ToString());
               SqlCommand objCommand = new SqlCommand();
               SqlDataReader dr;
               objConnection.Open();
               objCommand.Connection = objConnection;
               objCommand.CommandType = CommandType.Text;
               objCommand.Parameters.Clear();
               objCommand.CommandText = "select Count(*) from Table_Name where [UserId]=''" + UserId + "'' and [Password]=''" + Password + "'' and Status=''A'' ";
               int val = int.Parse(objCommand.ExecuteScalar().ToString());
               if (val > 0)
               {
                   while (dr.Read())
                   {
                       //like this retrieve all values
                       if (dr["UserId"] != System.DBNull.Value)
                       {
                           if (dr.HasRows == true)
                           {
                               int UserId = Convert.ToInt32(dr["UserId"]);
                           }
                       }
                       if (dr["Password"] != System.DBNull.Value)
                       {
                           if (dr.HasRows == true)
                           {
                               string Slno = dr["Password"];
                           }
                       }
                   }
               }


如果您成功保存了详细信息,那么从数据库中检索详细信息有什么问题?
只需从数据库中检索凭证,然后比较在登录按钮中为用户ID和密码字段输入的值,如果匹配则将用户重定向到另一个页面(登录后可以查看的页面),否则显示未找到消息凭证. br/>
以上为简单登录的过程.
除了这些出于安全性目的,您还可以在应用程序中提供身份验证和身份验证.
if u saved the details successfully then what is the problem in retrieving them from database ?
just retrieve the credentials from database then compare the values entered for user Id and password fields in login button click if matched redirect the user to another page (the page which can be viewed after logging in),else display a message credentials not found.

the above process for simple login.
In addition to these for security purpose you can provide authentication and autherization in your application.


这篇关于如何从登录页面的后端到前端读取数据库值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆