excel - inserting data with OleDb c#

Posted by Cmptrb on Stack Overflow See other posts from Stack Overflow or by Cmptrb
Published on 2010-04-06T00:39:04Z Indexed on 2010/04/06 0:43 UTC
Read the original article Hit count: 318

Filed under:
|
|

Hi,

my code is below:

private string connectionstring = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\myexcel.xls; Extended Properties=""Excel 8.0;HDR=YES;""";

this is my connection string, the excel file is created writable (not readonly)

either my command to insert any data is :

string commandstring = "insert into [mus$] (name, surname) values('mickey', 'mouse')";

But my commandstring does not work and gives the error: "number of query values and destination fields are not the same"

Where I do mistake ?

© Stack Overflow or respective owner

Related posts about c#

Related posts about oledb