So I put the database into the dubug folder in bin of my project, and in the data source configuration wizard i selected ms access and my file, then i copied my connection string, it was "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\bin\Debug\bookshop.mdb" and wrote some code for it to connect to it, to be exact, i used the code in this webpage: http://www.rollybueno.info/how-to-create-login-form-in-vb-net/ and when i debug it and enter the username and password, i getthe "failed to connect to database" that was made by the cod,i checked to see if i had missed some lines of code or just a symbol, i haven't, I searched so much and couldn't find a solution, can someone please help, thanks in advance
here is my code
`Public Class frmLogin
Private Sub btnSI_Click(sender As Object, e As EventArgs) Handles btnSI.Click
Dim u As String = txtUN.Text
Dim p As String = txtPW.Text
If u = "admin" And p = "admin123" Then
Me.Hide()
frmSystemAdmin.Show()
Else
Dim conn As New System.Data.OleDb.OleDbConnection()
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\bin\Debug\bookshop.mdb"
Try
Dim sql As String = "SELECT * FROM Login WHERE username='" & u & "' AND password = '" & p & "'"
Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql)
sqlCom.Connection = conn
conn.Open()
Dim sqlRead As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader()
If sqlRead.Read() Then
frmCashier.Show()
Me.Hide()
Else
MessageBox.Show("Username and Password do not match..", "Authentication Failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
p = ""
u = ""
txtUN.Focus()
End If
Catch ex As Exception
MessageBox.Show("Failed to connect to Database..", "Database Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub
End Class`