Wednesday, October 27, 2010

VB.NET (Wndows) Fill Datagrid with Access table

Imports System.Data.OleDb

Dim oConn As OleDbConnection
        Dim oComm As OleDbDataAdapter
        Dim sConn As String
        Dim sComm As String
        Dim oDataSet As New DataSet
        sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\avs.mdb;Persist Security Info=False"
     
        oConn = New OleDbConnection(sConn)
        sComm = "select distinct party from avst"
        oComm = New OleDbDataAdapter(sComm, oConn)
        oComm.Fill(oDataSet, "avst")

        DataGridparty.DataSource = oDataSet.Tables("avst").DefaultView
        DataGridparty.Refresh()

No comments: