Hello
I'm working on a local mdb file.

I can send to Oledbdataadapter constructor 2 string variables.

I looked in MSDN and they say I still have to open connection with Oledbconnection to connect to my mdb file.

but I can work regulary without opening the connection.

Imports System.Data
Imports System.Data.OleDb


Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Dim constr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users.mdb;"
            Dim ds As New DataSet()
            Dim cmd As String = "SELECT * FROM Users"

            Dim da As New OleDbDataAdapter(cmd, constr)
            da.Fill(ds, "Users")
            DataGridView1.DataSource = ds.Tables("Users")
        Catch ex As Exception
            MsgBox("File Not Found")

        End Try

    End Sub
End Class

in this way I can insert rows delete cells and everything
so why do I need the Oledbconnection?

Your OleDbDataAdapter is creating the OleDbDataConnection for you under the hood. You're still using it.

Help file:

OleDbDataApater Class
Represents a set of data commands and a database connection that are used to fill the DataSet and update the data source.

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.