C#,oledb连接字符串问题 [英] c#, oledb connection string issue

查看:142
本文介绍了C#,oledb连接字符串问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用.net4.0和c#语言. 在我的代码中,我有一个连接字符串

I'm using .net4.0 and c# language. In my code i have a connection string

oleConnection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;
                   Data Source = " + filepath + ";
           Extended Propertie s= \"Excel 12.0;HDR=yes\"";

,效果很好.但是当我更改这样的连接字符串时:

and it work well. But when i change a connection string like this:

oleConnection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;
                   Data Source =" + filepath + "; 
           Extended Properties =\"Excel 12.0;HDR=no\"";

(我将HDR参数更改为否") 我收到错误消息:没有为一个或多个必需参数提供任何值. "Microsoft Office Access Database Engine".

(I change HDR parameter for "no") I got error: No value given for one or more required parameters. error from "Microsoft Office Access Database Engine".

推荐答案

如果您使用[A1]引用列,则此操作将失败. HDR = No时,列被引用为F1,F2等.

If your referencing a column using say [A1] then this will fail. With HDR=No the columns are referenced as F1, F2 etc.

这篇关于C#,oledb连接字符串问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆