Click here to Skip to main content
15,897,226 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

I created web application, in this application there is a part of insert Large string (String having more than 10000 characters) values in to excel sheet using oledb query.
i have tried the below code but i am getting
"The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data" this error.

C#
string con = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Mohan.G\WorkTimeSheet\Test.xls;Extended Properties=Excel 8.0;";
            using (OleDbConnection connection = new OleDbConnection(con))
            {
                connection.Open();
                        string str ="bsdhjbfdggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggdfgdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddshjfbdhjsfsbjfsbfhjsfbjhbfjhbfjhsbhfshjfjfbjhfjshfjhsfjshfjdhsfjsjfdsjfjjglfgjlkjgoig/dfdfgflkdglkfgfjlkgkjldfglklfggjoitglklkfjdgoidjgldmgldgogloieewrlkrj/k.asuhdidkahdsdhisuahdiuhsikudhiusadhiusdhishdisiduhidhsihahudihiuhisahdiuhiai";
                string sqlStquery = "Insert into [Sheet1$] ([ID],[Name]) Values ('" + 0 + "','" + str + "')";

                OleDbDataAdapter dbadapter = new OleDbDataAdapter(sqlStquery, connection);
                dbadapter.SelectCommand.ExecuteNonQuery();
                dbadapter.Dispose();
                connection.Close();
                connection.Dispose();
            }






so can any one suggest me how to insert more than 10000 character string value into Excel sheet using Oledb Query.


Thanks in Advance,
Mohan G
Posted
Updated 27-Dec-13 23:05pm
v4
Comments
Richard MacCutchan 28-Dec-13 4:44am    
The same way that you would insert any length of string. Create an INSERT command with the correct parameters and run it as normal.
Mohan Gopi 28-Dec-13 5:02am    
Hi Richard,

Thanks for your reply. i will add my code in my query just check it.

Use this library instead of OLEDB which might be size limited : http://epplus.codeplex.com/[^]
 
Share this answer
 
Comments
Mohan Gopi 28-Dec-13 6:29am    
Hi Mehdi,

Thanks for your reply. i think this library will support only for .xlsx file format. in my case i have .xls excel file format, so please suggest me how to use this library for inserting excel sheet using this library. if you provide sample code means its very useful to me.
Mehdi Gholam 28-Dec-13 7:50am    
The library has source code and samples and documentation at that site.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900