Click to See Complete Forum and Search --> : Stopping Excel process inside C#?


kobus
July 18th, 2005, 04:44 AM
Hi

I am connecting to an Excel workbook using the Microsoft.Jet.OLEDB in a C# windows application.

I create a connection string (OleDbConnection conn = new OleDbConnection(connString);) and manages to open the connection and retrieve data from the workbook into a OleDbDataReader.
At the end of the method I close the connection (using conn.Close()).

In the task manage however I see that EXCEL is stil an active process and I cannot open any of my Excel workbooks until I stop the EXCEL process in the Task Manager.

How will I stop the excel process insede my C# code?

Thanks

Kobus

exterminator
July 18th, 2005, 05:34 AM
Why should a process "EXCEL" start when you are making an oledbconnection. I havent noticed it yet! i guess it wont have to do anything with the connection. Guys..correct me if I am wrong.

Also, you could try calling Dispose() method of the connection class and see what happens. :thumb:

Andy Tacker
July 19th, 2005, 08:26 AM
you have to explicitly close Excel Application. When you open Workbook, you can get the pointer to Excel application. and simply call excel application's quit method.

I am not sure about your project, but why dont you opt for Office Automation?

[moved thread to C# forum)

exterminator
July 19th, 2005, 10:46 AM
Are you accessing this excel file in some other method except for this where you are creating an OleDbConnection? That might be causing issues if not closed well. Try posting you code in <code> tags whereever you are trying to access anything related to excel. That might help us get to the core of the issue. Cheers. :thumb:

Andreas Masur
July 19th, 2005, 12:08 PM
[ Merged threads ]