:: Home     :: MS Dynamics CRM     :: .Net 1.1     :: .Net 2.0     :: Sharepoint Portal     :: Ajax


Binding a Datagrid to an Access Database

Given below is an example piece of code to illustrate binding a datagrid to an Access database.

Sub BindDataGrid()
    Dim MyCommand As OleDbCommand
    Dim myConnection as OLEDBConnection
    Dim myDatareader as OLEDBDataReader
    Dim myAdapter as OLEDBDataAdapter
    Dim myDataSet As DataSet
    dim sqlString As String
    myConnection = New oleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="&server.mappath("/myDatabase.mdb"))
    sqlString = "SELECT * FROM myTable
    myAdapter = New OLEDBDataAdapter(sqlstring, myConnection)
    myDataSet = new DataSet myAdapter.fill(myDataSet, "pictures")
    myDataGrid.DataSource = myDataSet
    MyCommand = Nothing
    myConnection = Nothing
    myDatareader = Nothing
    myAdapter = Nothing myDataSet = Nothing
    sqlString = Nothing
End Sub

Copyright 2005-2015, Megasolutions Ltd  |   Privacy Policy