how to specify the connection string if the excel file name contains white space?using c#

前端 未结 4 1672
北荒
北荒 2020-12-12 01:22
string connString = \"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\\\data\\\\[Proj_Resource Details 20110118.xlsx];Extended Properties=Excel 12.0\";
         


        
4条回答
  •  伪装坚强ぢ
    2020-12-12 01:56

    Have you tried it as just

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

    without the []s?

    By the way, if you are not escaping 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";
    

提交回复
热议问题