View Single Post
  #5 (permalink)  
Old April 8th, 2008, 11:27 AM
WestAussie WestAussie is offline
Registered User
 
Join Date: Apr 2008
Location: , , Australia.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Peter

I tried to determine if there was any data in the DataSet but wasn't sure of the best way to do this. (What is the right way to check if a DataSet contains data?)

So I changed the Command object to reference a table using the following code and the data is displayed as it should be.

      objConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0 ;Data Source=C:\MyDatabase.accdb;Persist Security Info=False;")

        'Initialize a new instance of the OleDbCommand class.
        objCommand = New OleDbCommand

        'Set command object properties.
        objCommand.CommandText = "tblMyAccessTable"
        objCommand.CommandType = CommandType.TableDirect
        objCommand.Connection = objConnection

        'Initialize a new instance of the Adapter class.
        objDataAdapter = New OleDbDataAdapter

        'Initialize a new instance of the DataTable class.
        dt = New DataTable

        'Set the SelectCommand for the DataAdapter.
        objDataAdapter.SelectCommand = objCommand

        'Populate the DataTable.
        objDataAdapter.Fill(dt)

        Me.DataGridView.DataSource = dt

I must be missing a step in populating the data into a DataSet within my previous code. Any ideas as to what it might be?
Reply With Quote