"Maximum open cursors exceeded" in oracle when uploading a Excel sheet into oracle database using ASP.NET and C#
<p>i have to upload a excel file with 4000 records into oracle database using asp.net and c#.but it uploads only a portion of the records and gives the error "Maximum open cursors exceeded".how can i solve this error? </p>

<p>`` public void Button1_Click(object sender, EventArgs e)
    {
        String savePath = @"C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\WebSites\ABC\Uploads\";</p>

<pre><code>    if (FileUpload1.HasFile)
    {

        String fileName = FileUpload1.FileName;
        savePath += "NewMaster.xls";

        FileUpload1.SaveAs(savePath);

        Label1.Text = "Your file was saved successfully" ;


    Excel.ApplicationClass app = new ApplicationClass();     
    Excel.Workbook workBook = app.Workbooks.Open(savePath, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);            

    Excel.Worksheet workSheet = (Excel.Worksheet)workBook.ActiveSheet;
    int index = 1;
    object rowIndex = 1; 
    object colIndex1 = 1;   
    object colIndex2 = 2; 
    object colIndex3 = 3;
    object colIndex4 = 4; 
    object colIndex5 = 5;
    object colIndex6 = 6;
    object colIndex7 = 7;
    object colIndex8 = 8; 
    object colIndex9 = 9;
    object colIndex10 =10;
    object colIndex11 = 11;
    object colIndex12 = 12;
    object colIndex13 = 13;
    object colIndex14 = 14;
    object colIndex15 = 15;
    object colIndex16 = 16;
    object colIndex17 = 17;


    UYear = DateTime.Today.Year.ToString();
    UMonth = DateTime.Today.Month.ToString();
    UDay = DateTime.Today.Day.ToString();
    UTime=DateTime.Now.ToLongTimeString();
    UMonth = FormatDate(UMonth);
    UDay = FormatDate(UDay);
   UDate = UYear + UMonth + UDay;


    try            
    {  
        while (((Excel.Range)workSheet.Cells[rowIndex, colIndex1]).Value2 != null)                
        {                                  
            string Ref_no = Removespaces(drop_null(Convert.ToString(((Excel.Range)workSheet.Cells[rowIndex, colIndex1]).Value2)));
            string Title =Removespaces( PrepareApostrophe(drop_null(Convert.ToString(((Excel.Range)workSheet.Cells[rowIndex, colIndex2]).Value2))));
            string CustomerName = PrepareApostrophe(drop_null(Convert.ToString(((Excel.Range)workSheet.Cells[rowIndex, colIndex3]).Value2)));
            string NIC = RemoveFirstSpaces(Removespaces(drop_null(Convert.ToString(((Excel.Range)workSheet.Cells[rowIndex, colIndex4]).Value2)))); 
            string Year =Removespaces( drop_null (Convert.ToString (((Excel.Range)workSheet.Cells[rowIndex, colIndex5]).Value2)));
            string YaerDot =drop_null(Convert.ToString ( ((Excel.Range)workSheet.Cells[rowIndex, colIndex6]).Value2));
            string Month = Removespaces(drop_null(Convert.ToString(((Excel.Range)workSheet.Cells[rowIndex, colIndex7]).Value2)));
            string MonthDot = drop_null (Convert.ToString (((Excel.Range)workSheet.Cells[rowIndex, colIndex8]).Value2));
            string Date = Removespaces(drop_null (Convert.ToString(((Excel.Range)workSheet.Cells[rowIndex, colIndex9]).Value2)));
            string Address1 = PrepareApostrophe(drop_null(Convert.ToString(((Excel.Range)workSheet.Cells[rowIndex, colIndex10]).Value2)));
            string Address2 = PrepareApostrophe(drop_null(Convert.ToString(((Excel.Range)workSheet.Cells[rowIndex, colIndex11]).Value2)));
            string Address3 = PrepareApostrophe(drop_null(Convert.ToString(((Excel.Range)workSheet.Cells[rowIndex, colIndex12]).Value2)));
            string status = Removespaces(PrepareApostrophe(drop_null(Convert.ToString(((Excel.Range)workSheet.Cells[rowIndex, colIndex13]).Value2))));
            string mobileeNo = Removespaces(drop_null(Convert.ToString(((Excel.Range)workSheet.Cells[rowIndex, colIndex14]).Value2)));
            string telephoneNo = Removespaces(drop_null(Convert.ToString(((Excel.Range)workSheet.Cells[rowIndex, colIndex15]).Value2)));
           string commencement_date = Removespaces(drop_null(Convert.ToString(((Excel.Range)workSheet.Cells[rowIndex, colIndex16]).Value2)));



            string insertOriginal = "insert into abc.def(REF_NO,TITLE,CUS_NAME,NIC,YEAR1,MONTH1,DATE1,ADDRESS1,ADDRESS2,ADDRESS3,CIVIL_STATUS,MOBILE_NO,TELE_NO,COMMENCEMENT_DATE,UDATE,UTIME)" +
                             " values('"+Ref_no +"','"+Title+ "', '"+ CustomerName + "','" + NIC  + "','"+Year+"','"+Month +"','"+Date+"','"+Address1+"','"+Address2 +"','"+Address3 +"','"+status +"','"+mobileeNo +"','"+telephoneNo +"','"+commencement_date +"','"+UDate +"','"+UTime +"')";
            dm.insertRecords(insertOriginal);
</code></pre>

<p>catch (Exception ex)<br>
        {<br>
            Label1.Text = ex.Message;<br>
        } </p>

<pre><code>    }
    else
    {
        Label1.Text = "You did not specify a file to upload.";

    }

        }
</code></pre>
