0

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?

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by sknake
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.