Solved

How to prevent the error ["InvalidOperationException" was unhandled. Timeout expired.] when creating multiple Excel files from a C# application using VS2005?

Posted on 2013-01-14
2
586 Views
Last Modified: 2013-01-14
I am developing a C# Windows platform application using VS2005.

The application creates multiple Excel files using a FOR LOOP.

After about 40 Excel files are created my C# application aborts with:

InvalidOperationException was unhandled.

Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool.

This may have occurred because all pooled connections were in use and max pool size was reached.

I inspected the Windows Task Bar and clicked on the Processes tab:
Under the column titled "Image Name", I see an EXCEL.EXE row for every Excel file the application created. Each of the EXCEL.EXE rows has a memory usage value of about 25,500K.

After 40 Excel files were created, the application aborted and I noticed in Task Manager that 40 rows were created with an Image Name of EXCEL.EXE.

How would I prevent creating a separate EXCEL.EXE for each file generated?

My code is attached in a text file.
ExcelFiles.txt
0
Comment
Question by:zimmer9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 3

Expert Comment

by:contactnaeem
ID: 38775984
I assumed you are calling BranchToExcel in a look, irrespective of this in BranchToExcel method you opend sqlconnection but did not close. After getting data just close connection and dispose command objects.

Also you created below three objects but never used them just remove these objects if not used or close them propperly.

Excel.Application xlApp;
 Excel.Workbook xlWorkBook;
 Excel.Worksheet xlWorkSheet;
0
 
LVL 3

Accepted Solution

by:
contactnaeem earned 500 total points
ID: 38775985
sorry look=loop
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question