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
Loading
kobus_2000Posted Jul 19, 2005, 12:34 AM
I shall try the code tonight.
Kobus
Mike GoldPosted Jul 18, 2005, 11:04 PM
it keeps reference counts of COM objects, and they aren't always decremented or incremented
properly. So what you have to do is forcefully kill the process. See code below:
using System.Diagnostics;
Process[] processes = System.Diagnostics.Process.GetProcessesByName("EXCEL");
foreach (Process p in processes){
p.Kill();
} -Mike G.