Hi,
I am using VS 2010, c#.
I am inserting records from an excel file, which contains 6000 records to a custom list.
I am using the Visual webpart, and oledb connection. I am not using the openXML format, as i need to use "xls" and "xlsx" type.
I am doing the below steps currently:
1) From the file upload control, i am saving the excel to the sharepoint layouts - inside that a custom folder, to keep the records.
2) Using the oledb connection to read the records and fill it in a datatable.
3) Inserting the datatable values to a custom list.
Looping through the datatable and inserting 3000 – 4000 records to List, I am getting the "Request timeout error".
Below is the sample code, where i am looping the datatable and inserting the record:
SPList prjCmpList = oWeb.Lists[strListName];
SPListItemCollection prjCmpListItems = prjCmpList.Items;
SPListItem prjCmpListItem;
foreach (DataRow dr in dt.Rows)
{
try
{
prjCmpListItem = prjCmpListItems.Add();
prjCmpListItem["Title"] = dr[0];
prjCmpListItem["FirstName"] = dr[1];
prjCmpListItem.Update();
}
catch (Exception)
{
}
}I am using the "using block" for the spsite and web objects. When I see the execution time out in my web.config it is set to 3600. But I am getting the request time out after 2 mins only.
I have checked these link's : http://msdn.microsoft.com/en-us/library/aa973248%28v=office.12%29.aspx
http://www.etechplanet.com/blog/how-to-import-an-excel-spreadsheet-in-sharepoint-and-save-it-as-a-custom-list.aspx
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/8664375c-fae0-483a-b43f-ce7d353b896a/importing-3000-records-to-sharepoint-list-causing-requesting-time-out-error?forum=sharepointadminlegacy
However, I am following the best practices, and also the insertion of records is to be done programmatically.
Has anyone faced this kind of issue? How to fix this?