Visual Studio 2017中的登录页面 [英] Login page in visual studio 2017
本文介绍了Visual Studio 2017中的登录页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为我的软件创建一个登录页面,但登录查询仍然失败!
我的设计: 设计图片
我的数据库:数据库图像
然而,每次执行程序时都会出错: 错误图片
我从此YouTube视频获得此代码: Visual Studio 2012 - 2015 Microsoft Access登录VB.NET - YouTube
我的尝试:
我的公司de:< pre lang =vb> Public Class LoginForm
Private Sub QuitButton_Click(sender As Object,e As EventArgs)Handles QuitButton.Click
Me.Close()
End Sub
Private Sub SubmitButton_Click(sender As Object,e As EventArgs)处理SubmitButton.Click
Dim user As String
Dim pass As String
user = UserTextBox.Text
pass = PassTextBox.Text
If UsersTableAdapter.LoginQuery(user,pass)Then
MsgBox(User Authenticated!)
Else
MsgBox(Invalid Credentials! )
End if
End Sub
End Class
我的查询:
SELECT 用户名,[密码]
FROM Users
WHERE(用户名=?) AND ([密码] =?)
解决方案
:叹息:
YouTube视频如何编码安全性......和纸巾水壶一样有用。
停止尝试从YouTube编码 - 很明显作者完全不知道他是什么这样做。
切勿以明文形式存储密码:这是一个主要的安全风险。始终哈希它们,并比较哈希值。 密码存储:如何操作。 [ ^ ]解释 - 代码在C#中,但它是非常明显的东西。
没有你的UsersTableAdapter.LoginQuery
代码我们不能准确地告诉那里发生了什么,但错误意味着你的一个或另一个参数是错误的 - 系统试图将它转换为布尔
值,然后再传递给它SQL。
I am creating a login page, for my software, but the login query keeps failing!
My Design: Design Image
My Database: Database Image
Yet, every time I execute the program I get an error: Error Image
I got this code from this YouTube video: Visual Studio 2012 - 2015 Microsoft Access Login VB.NET - YouTube
What I have tried:
My Code: <pre lang="vb">Public Class LoginForm Private Sub QuitButton_Click(sender As Object, e As EventArgs) Handles QuitButton.Click Me.Close() End Sub Private Sub SubmitButton_Click(sender As Object, e As EventArgs) Handles SubmitButton.Click Dim user As String Dim pass As String user = UserTextBox.Text pass = PassTextBox.Text If UsersTableAdapter.LoginQuery(user, pass) Then MsgBox("User Authenticated!") Else MsgBox("Invalid Credentials!") End If End Sub End Class
My Query:
SELECT Username, [Password]
FROM Users
WHERE (Username = ?) AND ([Password] = ?)
解决方案
:sigh:
YouTube videos of "how to code security" ... about as useful as a tissue-paper kettle.
Stop trying to code from YouTube - it's pretty clear that the author has absolutely no idea what he is doing.
Never store passwords in clear text: it's a major security risk. Always hash them, and compare the hashes. Password Storage: How to do it.[^] explains - the code is in C# but it's pretty obvious stuff.
Without yourUsersTableAdapter.LoginQuery
code we can't tell exactly what is happening there, but the error implies that one or other of your parameters is wrong - the system is trying to cast it to aBoolean
value before it passes it to SQL.
这篇关于Visual Studio 2017中的登录页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文