I found a more efficient way to deal with this problem, my links are the two links below
http://support.microsoft.com/kb/316934
http://www.codeproject.com/Articles/37055/Working-with-MS-Excel-xls-xlsx-Using-MDAC-and-Oled
Basically, don't use a data adapter, dataset and options to insert rows in Excel (this never worked for me) instead, run SQL insert from code directly using the command object
Here is what you need to do
- Declare a wide field as MEMO instead of a string or CHAR "CREATE TABLE WorkSheetName (field1 INT, field2 MEMO, field3 ...);"
- Create an insert statement like "INSERT INTO WorkSheetName (field1, field2, ...) VALUES (1234," Any long line here ... ", ...)"
Declare DbCommand to run the Create table and Insert views above, here I use the obj command from the corporate library
DbCommand dbCommand = m_dbConnection.CreateCommand (); dbCommand.CommandText = "Create table ..."; dbCommand.CommandType = CommandType.Text; dbCommand.ExecuteNonQuery ();
dbCommand.CommandText = "Insert Into ..."; dbCommand.CommandType = CommandType.Text; dbCommand.ExecuteNonQuery ();
source share