Below i write the coding which is not working properly yo me.I want to open excel file and use select statement with where clause.But one I run the coding it give me exception it says
"No Value give for one or more parameters"
Pls help me.

Excel.Workbook theWorkbook = ExcelObj.Workbooks.Open("C:\\Shop Transfer1.xls", 0, false, 5, "", "", true, Excel.XlPlatform.xlWindows, "", true, false, 0, false, true, false);

            // get the collection of sheets in the workbook
            Excel.Sheets sheets = theWorkbook.Worksheets;
            // get the first and only worksheet from the collection of worksheets
            MessageBox.Show(sheets.Count.ToString());
            Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(1);
            string str1 = "Select * from [Sheet1$] where ShopCode='"+00016658+"'";           
                    

            OleDbCommand command1 = new OleDbCommand(str1, olecon);
            DataSet da = new DataSet();
            OleDbDataAdapter adapter = new OleDbDataAdapter(command1);
            adapter.Fill(da);
             dataGridView1.DataSource = da.Tables[0];

Thanks

Recommended Answers

All 2 Replies

On which line?

might try [ShopCode] if your error is in that line

also use columns instead of star

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.