How to specify connection string if excel file name contains space? WITH#

string connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\data\\[Proj_Resource Details 20110118.xlsx];Extended Properties=Excel 12.0";

I mentioned [] is still throwing an exception. How can I solve this problem. plz indicate the correct path

+3
source share
3 answers

Wrap the entire file name in quotation marks, but since this literal string uses \ "to avoid them:

string connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\"D:\\data\\Proj_Resource Details 20110118.xlsx\";Extended Properties=Excel 12.0";
+3
source

Have you tried it as simple

string connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\data\\Proj_Resource Details 20110118.xlsx;Extended Properties=Excel 12.0";

without [] s?

By the way, if you are not avoiding anything, just use @

string connString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\data\Proj_Resource Details 20110118.xlsx;Extended Properties=Excel 12.0";
+2
source

string connString = @ "Provider = Microsoft.ACE.OLEDB.12.0; Data source = \" ** D: \ data \ Proj_Resource Details 20110118.xlsx \ "; ** Advanced properties = Excel 12.0";

0
source

Source: https://habr.com/ru/post/1788937/


All Articles