Click here to Skip to main content
15,903,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, I attach new DataSource and DataSet on Run Time. I set filter also in the Run Time but it shows error ""Cannot find column [invoice_number]"

my code is
C#
// Create a connection object. 
            OleDbConnection connection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:/Srihari/OrionSystem.accdb");

            // Create a data adapter. 
            OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM gridview", connection);

            // Create and fill a dataset. 
            DataSet sourceDataSet = new DataSet();
            adapter.Fill(sourceDataSet);

            // Specify the data source for the grid control. 
            gridControl1.DataSource = sourceDataSet.Tables[0];

            invoiceBindingSource.Filter = string.Format("invoice_number = '{0}'", textEdit5.Text);// error show n this line


but my OrionSystem Access Database having the Column "invoice_number" in the table gridview. What is my error ?
Posted

1 solution

Try This:

DataTable DataTable = null;
DataTable = sourceDataSet.Tables(0);

if (Information.IsDBNull(DataTable) == false) {
	DataView dataView = DataTable.DefaultView;
	dataView.Sort = "invoice_number asc";
	GridView1.DataSource = dataView;
        GridView1.DataBind();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900