Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27184

VB 2010 Login System with Database Error

$
0
0
So I am not using sql as this is just a small class project for my own personal knowledge. However, I looked at an example earlier and found that it worked. I can't find that example anymore and I can't figure out what the person did to make it work. (It was a simple fix). So hopefully you will be able to help me find my solution in my coding. Thanks
-TurnedTurquoise

Coding:
Please pay attention closely to the btnOkay_Click as that is the issue part. My problem when I run the program is that it takes my Username and Password from the query and uses it as a boolean. Since I thought of that, I thought that if it checked the Username and Password typed with the Username and Password in the query, that it would set "login = true", therefore checking if the Username or Password is correct in the database. Keep in mind I am stubborn and don't want to use sql and this is what I'm trying to do. Thank you for your time.

Public Class frmLogin

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
End
End Sub

Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
txtUsername.Text = ""
txtPassword.Text = ""
End Sub

Private Sub AccountsBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs)
Me.Validate()
Me.AccountsBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.MainDatabaseDataSet)

End Sub

Private Sub frmLogin_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'MainDatabaseDataSet.Accounts' table. You can move, or remove it, as needed.
Me.AccountsTableAdapter.Fill(Me.MainDatabaseDataSet.Accounts)

End Sub

Private Sub btnOkay_Click(sender As Object, e As EventArgs) Handles btnOkay.Click
Dim Username As String
Dim Password As String
Username = txtUsername.Text
Password = txtPassword.Text
Dim login As Boolean
login = Me.AccountsTableAdapter.ScalarQueryLogin(Username, Password)
If login = True Then
MsgBox("Welcome " + Username)
Else
MsgBox("You have entered the wrong credentials.")
End If
End Sub
End Class

Viewing all articles
Browse latest Browse all 27184

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>