开发者

C#, Excel, OleDB, Insert statement not working

I haven't found anyone with a similar problem so I'm asking for help. I wrote a simple program that is supposed to read data from an Excel spreadsheet(A) and after doing some calculations will insert computed data into a different spreadsheet(B).

I can execute SELECT commands without any problems but when I execute an INSERT command with ExecuteNonQuery it returns 1(meaning 1 row affected) and yet nothing is inserted into the spreadsheet.

I open the file without the Imex parameter in the connection string. I even tried adding this parameter but got an exception.

the insert statement is(example):

Insert into [Test$](F3,F4,F5,F6,F9,F10,F11,F15,F16,F17,F18,F19,F20,F21,F22,F23,F24,F25,F26) values('1','1','1','2010-07-12','PR','C','P','1','R','OR',null,null,null,开发者_C百科null,null,null,null,null,null)

EDIT

It seems like the source of the problem is the spreadsheet itself. Any ideas why?


Follow the following link:

It has a very simple code and it works fine for me:

http://csharp.net-informations.com/excel/csharp-excel-oledb-insert.htm

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜