can any1 help me to connect my project to ms access database. i'm a newbie in vb.net. this is my code in vb6 to connect to the database can any1 help me to do it vb.net..hope sumbody can help me..

this is how i do it in vb 6
1. project>reference>ms ADO 2.5
2. declaration

dim conn1 as adodb.connection
dim rs1 as adodb.recordset
dim strsql as string

set conn1 = new connection
set rs1 = new recordset

conn1.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\database\db2.mdb;Persist Security Info=False"

sql3 = "SELECT * FROM logs2 WHERE status1 = 'In' "
rs1.Open strsql3, conn, adOpenStatic, adLockOptimistic

If Not rs1.EOF And Not rs1.BOF Then
msgbox "Found"
else
msgbox "not Found"
end if

can any body help me to teach how i will convert it to vb.net. i try this code but it doesn't work of course ^_^..

THANK YOU in advance..

try this following code :

Dim con As New OleDb.OleDbConnection
    Dim cmdOle As New OleDb.OleDbCommand
    Dim dsOle As New DataSet
    Dim da As New OleDb.OleDbDataAdapter
    Dim dtOle As New DataTable
    Dim sql As String

    Private Sub LoadData()
        con.ConnectionString = ("Provider = Microsoft.JET.OLEDB.4.0;Data Source= D:\Only Me\Authors.mdb")
        Try
            cmdOle = con.CreateCommand
            cmdOle.CommandText = "SELECT * FROM Authors "
            da.SelectCommand = cmdOle
            da.Fill(dsOle, "Authors")
            dgAuthor.DataSource = dsOle
            dgAuthor.DataMember = "Authors"
            dgAuthor.ReadOnly = True
        Catch ex As Exception
            MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, "Koneksi Error !!")
        End Try

    End Sub

    Private Sub Search_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadData ' Call Load Data Procedure in form load to fill datagrid
    End Sub

    Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click

        con.ConnectionString = ("Provider = Microsoft.JET.OLEDB.4.0;Data Source= D:\Only Me\Authors.mdb")
        Try
            dsOle.Clear()
            dtOle.Clear()
            cmdOle = con.CreateCommand
            cmdOle.CommandText = "SELECT * FROM Authors where YearBorn LIKE '%" & Trim(txtSearchKey.Text) & "%'"
            da.SelectCommand = cmdOle
            da.Fill(dsOle, "Authors")
            dgAuthor.DataSource = dsOle
            dgAuthor.DataMember = "Authors"
            dgAuthor.ReadOnly = True

        Catch ex As Exception
            MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, "Connection Error !!")
        End Try
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.