OleDbConnection 从索引 166 处开始,初始化字符串的格式不符合规范。

连接Excel 提示   从索引 166 处开始,初始化字符串的格式不符合规范。

原来机器只安装的wps测试没问题 连接字符串是 String.Format(@"Provider=Microsoft.Ace.OleDb.12.0;Persist Security Info=False;Data Source={0};Extended Properties=\Excel 12.0;HDR=YES;IMEX=1;\", FilePath);

出错原因是 Extended Properties里面的内容没有加引号

String.Format(@"Provider=Microsoft.Ace.OleDb.12.0;Persist Security Info=False;Data Source={0};Extended Properties=""Excel 12.0;HDR=YES;IMEX=1;""", FilePath);

posted on 2012-10-10 11:44  freexiaoyu  阅读(2061)  评论(0编辑  收藏  举报