c#, oledb connection string issue

2019-07-16 19:01发布

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\"";

(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".

3条回答
The star\"
2楼-- · 2019-07-16 19:21

OleDb Connection HDR Default is YES ans there is no option for that.

Check:

Connection strings for Access 2007

Regards

查看更多
疯言疯语
3楼-- · 2019-07-16 19:24

There is no HDR=no....

The default behavioour is no headers. So just leave out the HDR part completely - that will also mean no headers.

More info: http://msdn.microsoft.com/en-us/library/ms254500.aspx

查看更多
来,给爷笑一个
4楼-- · 2019-07-16 19:41

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

查看更多
登录 后发表回答