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.mdb" and in this database, I have created 1 table named "UserAccount" and it's fields are "ID", "UserName" & "Password"
I have write the code as following...
Expand|Select|Wrap|Line Numbers
- 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.