Click here to Skip to main content
15,894,254 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
This is login page code for verifying username and password from access database
VB
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       If TextBox1.Text = "" Or TextBox2.Text = "" Then
           MsgBox("ENTER USERNAME OR PASSWORD", MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation)

       else
       If ask() = True Then
           Employee.Show()
       Else
           MsgBox("INCORRECT USERNAME OR PASSWORD", MsgBoxStyle.OkOnly + MsgBoxStyle.Exclamation)
           End If
       End If
   End Sub

   Private Sub LoginForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       con.ConnectionString = "provider= microsoft.jet.oledb.4.0;data source = ..\debug\EmployeeFullDataBase.mdb"
   End Sub

   Public Function ask()
       Dim dt As New DataTable
       Dim ds As New DataSet
       ds.Tables.Add(dt)
       con.Open()
       Dim da As New OleDbDataAdapter("Select * from EmployeeFullData", con)
       da.Fill(dt)

       For Each DataRow In dt.Rows
           If TextBox1.Text = DataRow.item(11) And TextBox2.Text = DataRow(12) Then
               con.Close()
               Return True
           End If
       Next

       con.Close()
       Return False

   End Function
Posted
Comments
[no name] 12-Mar-15 13:06pm    
And what is the message of the error?
kirangambhir05 12-Mar-15 21:29pm    
im getting an error at con.open()
[no name] 12-Mar-15 21:32pm    
Please see the proposed solution below.

1 solution

The most likely culprit is the system type: if it's 64bit, then there is no 64bit version of the JET database engine, so the connection will fail.

Try using the ACE engine instead, and make sure that the DLL(s) are included in your installation software.

And please, never store passwords in clear text - it is a major security risk. There is some information on how to do it here: Password Storage: How to do it.[^]

It's a capital crime in many countries: CommitStrip[^] - or it should be.
 
Share this answer
 
Comments
[no name] 12-Mar-15 13:16pm    
+1 for a shot-in-the-dark answer and +4 for the CommitStrip - or the other way around, as you like :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900