安全登录...

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

我正在尝试读取登录信息,并根据Jet数据库中存储的用户名和密码对它们进行验证. 稍后我想使用SQL Server数据库,但是,我遇到了安装问题,因此我暂时使用Access.

I am trying to read logon information and validate them against stored user name and passwords within a Jet database. Later I want to use an SQL Server database, however, I have an installation problem, so I am using Access temporarily.

Logon.aspx.cs protected void Page_Load(object sender, EventArgs e) { System.Data.OleDb.OleDbConnection ConnectionToOleDb = new System.Data.OleDb.OleDbConnection("Provider= Microsoft.Jet.OLEDB.4.0;|DataDirectory|LibrarySystem.accdb"); try { //1. connect to database ConnectionToOleDb.Open(); //2. read logon credentials and match them to input ??? } catch (Exception ex) { throw ex; } //strongly typed errors need to be included.. finally { ConnectionToOleDb.Close(); } ... Logon.aspx function Submit1_onclick() { /* Logon credentials to be submitted and verified by the server control */ var user = document.getElementById('user').Value; var pwd = document.getElementById('pwd1').Value; if (user == "user") && (pwd == "password") { return true; document.forms[0].submit(); }

web.config ...

web.config ...

<configuration> <connectionstrings> <add name="CustomerDataConnectionString"> connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=|DataDirectory|LibrarySystem.accdb" providerName="System.Data.OleDb" /> </add></connectionstrings> ...</configuration>

推荐答案

不要在页面加载中执行任何操作.您应该在按钮单击事件"中创建连接并匹配凭据. 请参考具有访问权限数据库的登录表单 [ ^ ]. Don''t do anything in Page Load. You should create Connection and match credentials inside Button Click Event. Refer- Login form with access database[^] for one example.

更多推荐

安全登录...

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

发布评论

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

>www.elefans.com

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