Forum Moderators: open

Message Too Old, No Replies

Error during Excel Processing

         

txbakers

5:59 pm on Apr 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a routine that accepts an Excel file from a user and reads the data, then inserts it into the database.

If something goes wrong during the process, the EXCEL.EXE process continues to run and prohibits the person from uploading or reading another file. This is the error message thrown:

Win32 Error. Code: 1224. The requested operation cannot be performed on a file with a user-mapped section open

Is there a way to trap that error and if so, kill the Excel process?

TheNige

9:00 pm on Apr 12, 2006 (gmt 0)

10+ Year Member



Are you doing this in a try catch? Maybe you can close the excel application in the catch.

txbakers

10:45 pm on Apr 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



no, just doing it.

But if I did it in a try/catch, what is the command to close the process?

TheNige

10:38 pm on Apr 17, 2006 (gmt 0)

10+ Year Member



Are you using ASP or .Net? You can actually read from an Excel file using the OLEDB data drivers in .Net. That way you don't even have to open the Excel application.

How are you opening Excel now? If you are explicitly creating an Excel and document object you can try to close them in your catch like:

excelDoc.Close()
excelApp.Quit()

excelDoc and excelApp will be the name of your objects.

txbakers

12:58 am on Apr 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks - I'll give that a try!