C# Opening SQL Connection from Currently Opened Worksheet

时间:2016-12-09 12:58:37

标签: c# excel vsto

Can somebody help me regarding the problem I encountered in C# and Excel. Currently, my code goes like this:

string fname = Globals.ThisAddIn.Application.ActiveWorkbook.FullName;

con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fname + ";Extended Properties=\"Excel 8.0;HDR=" + hdr + "\"");

I am trying to connect to Excel worksheet as my database from my C# application. What bother's me is that, when the workbook or my database (fname) in the connection string above is currently open or when the con.Open() method is invoked, the application opens a readonly copy of the path, How could I prevent this?

Thank you!

0 个答案:

没有答案