G
Guest
Hello
I have a Windows Form that I am trying to use to display data in a DataGrid object from an Access Database. I have created an OleDbCommand Object (with the appropriate Connection string) to Select the appropriate data. I then use a OleDbDataAdapater to Fill a DataSet object. My problem is that I can't seem to show the results of the query on my datagrid object. Here is Code
private void btnSearch_Click(object sender, System.EventArgs e
OleDbDataAdapter dataAdapter = new OleDbDataAdapter()
DataSet dataSet = new DataSet()
//Here is the OleDbCommand object that has already been initalized with appropriate OleDbConnection objec
this.selectCustomersCmd.CommandText = "Select * From Customers"
dataAdapter.SelectCommand = this.selectCustomersCmd
dataAdapter.Fill(dataSet, "Customers")
//Show DataTable on DataGrid objec
this.dataGridObject.DataSource = dataSet.Tables["Customers"].DefaultView
}
I have a Windows Form that I am trying to use to display data in a DataGrid object from an Access Database. I have created an OleDbCommand Object (with the appropriate Connection string) to Select the appropriate data. I then use a OleDbDataAdapater to Fill a DataSet object. My problem is that I can't seem to show the results of the query on my datagrid object. Here is Code
private void btnSearch_Click(object sender, System.EventArgs e
OleDbDataAdapter dataAdapter = new OleDbDataAdapter()
DataSet dataSet = new DataSet()
//Here is the OleDbCommand object that has already been initalized with appropriate OleDbConnection objec
this.selectCustomersCmd.CommandText = "Select * From Customers"
dataAdapter.SelectCommand = this.selectCustomersCmd
dataAdapter.Fill(dataSet, "Customers")
//Show DataTable on DataGrid objec
this.dataGridObject.DataSource = dataSet.Tables["Customers"].DefaultView
}