[英]how to specify the connection string if the excel file name contains white space?using c#
string connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\data\\[Proj_Resource Details 20110118.xlsx];Extended Properties=Excel 12.0";
i mentioned [ ] still it is throwing exception.how can i solve this problem. 我提到[]仍然会引发异常。如何解决此问题。 plz mention the correct path
请提正确的路径
将整个文件名用引号引起来,但是因为这是一个文字字符串,请使用\\“将其转义:
string connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\"D:\\data\\Proj_Resource Details 20110118.xlsx\";Extended Properties=Excel 12.0";
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";
字符串connString = @“ Provider = Microsoft.ACE.OLEDB.12.0; Data Source = ”“ D:\\ data \\ Proj_Resource Details 20110118.xlsx \\”; **扩展属性= Excel 12.0“;
If you still cannot connect or get "Microsoft.ACE.OLEDB.12.0 provider is not registered on the local machine" error, you need to download the Microsoft Access Database Engine. 如果仍然无法连接或出现“未在本地计算机上注册Microsoft.ACE.OLEDB.12.0提供程序”错误,则需要下载Microsoft Access数据库引擎。
http://www.microsoft.com/en-us/download/details.aspx?id=13255 http://www.microsoft.com/zh-cn/download/details.aspx?id=13255
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.