SonicBoomAu
Well-known member
Hi All,
I am having problem retrieving information from an Access Database and putting that information into a DataGrid.
Here is my Code:
[VB]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Set strDatabaseName "C:\Database\database.mdb"
strDatabaseName = "Database Location"
Dim cnAdoNetConnection As New OleDb.OleDbConnection
Dim daDataAdapter As New OleDb.OleDbDataAdapter
Dim ds As New DataSet
Try
Open the connection to the database
cnAdoNetConnection.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
strDatabaseName
cnAdoNetConnection.Open()
Retrieve all the Asset Information
daDataAdapter = New OleDb.OleDbDataAdapter("SELECT * from DeletedAsset", _
cnAdoNetConnection)
daDataAdapter.Fill(ds)
DataGrid1.DataSource = ds.Tables
Close the connection to the database
cnAdoNetConnection.Close()
Catch ex As Exception
MessageBox.Show("An error has occurred! Error: " & ex.Message, _
"Title", MessageBoxButtons.OK, MessageBoxIcon.Error)
Close the connection to the database
cnAdoNetConnection.Close()
End Try
End Sub
[/VB]
Here is the Error I am receiving:
"Complex DataBinding accepts as a data source either an IList or an IListSource."
It throws the error up at the "DataGrid1.DataSource = ds.Tables" line.
If anyone knows of a good datagrid tutorial or example, could they please let me know.
Any help is greatly appreciated.
I am having problem retrieving information from an Access Database and putting that information into a DataGrid.
Here is my Code:
[VB]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Set strDatabaseName "C:\Database\database.mdb"
strDatabaseName = "Database Location"
Dim cnAdoNetConnection As New OleDb.OleDbConnection
Dim daDataAdapter As New OleDb.OleDbDataAdapter
Dim ds As New DataSet
Try
Open the connection to the database
cnAdoNetConnection.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
strDatabaseName
cnAdoNetConnection.Open()
Retrieve all the Asset Information
daDataAdapter = New OleDb.OleDbDataAdapter("SELECT * from DeletedAsset", _
cnAdoNetConnection)
daDataAdapter.Fill(ds)
DataGrid1.DataSource = ds.Tables
Close the connection to the database
cnAdoNetConnection.Close()
Catch ex As Exception
MessageBox.Show("An error has occurred! Error: " & ex.Message, _
"Title", MessageBoxButtons.OK, MessageBoxIcon.Error)
Close the connection to the database
cnAdoNetConnection.Close()
End Try
End Sub
[/VB]
Here is the Error I am receiving:
"Complex DataBinding accepts as a data source either an IList or an IListSource."
It throws the error up at the "DataGrid1.DataSource = ds.Tables" line.
If anyone knows of a good datagrid tutorial or example, could they please let me know.
Any help is greatly appreciated.