Searching and displaying data based on ID column from excel

Jul 13 2013 3:12 AM
I have window form & microsoft excel as database. I want to implement searching feature. i have 1 textbox 1 datagridview & 1 button & want whenever i click on button a search should be made in excel file based on the id provided in textbox & its description should be displayed in gridview.
The code i'm using is not dynamic its static i mean it'll only show description of data i provided in code & not in textbox ? 
Help me i urgently need this code ????
My Code is
 
private void srch()
{
string strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= 'c:\\Product Details.xlsx';Extended Properties='Excel 8.0;HDR=Yes;'";
// double id = Convert.ToDouble(textBox1.Text);
string query = "SELECT * FROM [Sheet1$]";  
DataSet excelDataSet = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(query, strConn); da.Fill(excelDataSet); dataGridView1.DataSource = excelDataSet.Tables[0];
DataView dv = ((DataTable)dataGridView1.DataSource).DefaultView;
DataView dv_filter = new DataView(); dv_filter.Table = excelDataSet.Tables[0];
dv_filter.RowFilter = "ID = '105'"; dataGridView1.DataSource = dv_filter;
}



Answers (1)