检查数据库中的登录字段 [英] check login fields from database

查看:88
本文介绍了检查数据库中的登录字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的登录表包含3条记录,那么如何检查输入的字段是否有效?

if my login table contain 3 records then how can i check the entered fields are valid

推荐答案

假设您的用户名位于txtusername.text中,密码为txtpassword.text

因此,在确定/登录按钮"单击事件上,检查以下内容

Suppose you have the user name in txtusername.text and password in txtpassword.text

So on the OK/Login Button click event, check the following

Dim rsLogin AS New ADODB.RecordSet
Set rsLogin = New ADODB.RecordSet

if (txtusername.text <> "") And (txtpassword <> "") Then
    rsLogin.Open "SELECT * FROM Login WHERE Uname = '" & txtusername.text & "' AND  password = '" & txtpassword.Text & "'"
Endif

if rsLogin.EOF = True then
    msgbox "Invalid UserName Or Password", VbCritical
    txtusername.SetFocus
Else
    msgbox "Successful Login"
Endif


希望这将帮助您解决问题


Hope This Will Help You To Solve Your Problem


我们可以使用LInQ代码来验证用户的存在,如下所示:

We can use LInQ code to validate the user existence as:

if (!db.Users.Any( u => u.UserName == argUser ))
{
  // Action code for valid user
}
else
{
  // Action code for in valid user
}


这篇关于检查数据库中的登录字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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