Excel and C#

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2008
Posts: 96
Reputation: Tank50 is an unknown quantity at this point 
Solved Threads: 1
Tank50's Avatar
Tank50 Tank50 is offline Offline
Junior Poster in Training

Excel and C#

 
0
  #1
Sep 10th, 2008
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
Last edited by Tank50; Sep 10th, 2008 at 6:05 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Excel and C#

 
0
  #2
Sep 10th, 2008
On which line?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,162
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Excel and C#

 
0
  #3
Sep 10th, 2008
might try [ShopCode] if your error is in that line

also use columns instead of star
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC