I have created the login form in vb.net
In this form there are 2 labels : Username & Password
and 2 Text-boxes for enter the username and password and 1 button "Login"
I have created the ms access database named "Project.md b" and in this database, I have created 1 table named "UserAccoun t" and it's fields are "ID", "UserName" & "Password"
I have write the code as following...
there is no error in this code, but when I run this form and though I enter the right username and password but "Not Accessed" msgbox is displays. I can't understand What changes I have to do in this code?
Which changes I have to do in this code? Please help.
In this form there are 2 labels : Username & Password
and 2 Text-boxes for enter the username and password and 1 button "Login"
I have created the ms access database named "Project.md b" and in this database, I have created 1 table named "UserAccoun t" and it's fields are "ID", "UserName" & "Password"
I have write the code as following...
Code:
Imports System.Data.OleDb
Public Class Login
Public con As New OleDbConnection("Provider=microsoft.jet.oledb.4.0 ; Data Source=E:\Brinda & Jay\Brinda\02 S.Y\VB.NET\My Project\Project.mdb")
Public qry As String
Public dr As OleDbDataReader
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
con.Open()
qry = "select * from UserAccount where UserName like ' " & TextBox1.Text & " ' and Password like ' " & TextBox2.Text & " ' "
Dim cmd As New OleDbCommand(qry, con)
cmd.CommandText = qry
cmd.Connection = con
dr = cmd.ExecuteReader
If dr.Read = True Then
MsgBox("Accessed")
Else
MsgBox("Not Accessed")
End If
con.Close()
End Sub
End Class
Which changes I have to do in this code? Please help.
Comment