i am cesar and i want to know on how to query records from ms access to the vb.net....any reply will be appreciated! thank you!

Recommended Answers

All 4 Replies

Are you trying to extract records from Access database into the vb.net application? If so, what do you want to display them in, Datagridview?

For reading only or for editing also?

yes...i want to display the records in datagridview..

Get your connection string from here:
http://www.connectionstrings.com/

Then:

Dim SampleConn As New OleDbConnection("Whatever Connection String You Need To Use Here")
Dim SampleAdapter As New OleDbDataAdapter("SELECT * FROM SampleTable", SampleConn)
Dim SampleDataSet As New DataSet
Dim SampleBind As New BindingSource

     Try

            SampleAdapter.Fill(SampleDataSet, "SampleTable")
            SampleBind.DataSource = SampleDataSet.Tables(0)
            Me.SampleDataGridView.DataSource = SampleBind
            SampleConn.Close()

        Catch ex As Exception

            MsgBox(ex.Message)

        Finally

            If SampleConn.State = ConnectionState.Open Then

                SampleConn.Close()

            End If

        End Try

This is off the top of my head so let me know how that works out for you. Obviously you need to change pretty much anything prefixed with "Sample" to your own system.

thank you for the code you give....this will be helpful for me..

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.