Hi My Name is Hefin Dsouza. From the very beginning i was in search for a simple way to authenticate users from a database there were many ways to do it. But all very complex so I was researching for a simple trick to complete my task and here it is. The Trick goes like this. Problem : I want to Authenticate username and passwords from users using VB.net where the user names and passwords are stored in the database.
Solution : Create a table with the username and password column add some details and save the table.
Now come the interesting part of connecting your application to your database and validate the Logins
In your login form where you may have two textbox’s for username and password.
On The Login buttons Click Event Write the Following Code.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim tex As String = "select * from login where username='" + TextBox1.Text + "' and [password]='" + TextBox2.Text + "'" dataAdap = New OleDbDataAdapter(tex, dataCon) dTable.Clear() dataAdap.Fill(dTable) If dTable.Rows.Count <> 0 Then MsgBox("Login Successfull", MsgBoxStyle.Information, "Login") Else MsgBox("Login UnSuccessfull", MsgBoxStyle.Critical, "Login") End If End Sub
That’s it And All Work Done and a Simple Login Box is ready to use.
This is a Simple way to Authenticate users in your application in a quick way.
If You have a better code please let me know.
Regards Hefin Dsouza
AttachmentsComplete Article with Screen Shots (20419-22621-Hi My Name is Hefin Dsouza.doc)Download the Source Code of an dummy Login Application (20419-22623-Login.zip)
|
No responses found. Be the first to respond and make money from revenue sharing program.
|