c#, oledb connection string issue

醉酒当歌 提交于 2019-12-11 03:10:05

问题


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


回答1:


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




回答2:


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

Check:

Connection strings for Access 2007

Regards




回答3:


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



来源:https://stackoverflow.com/questions/7684416/c-oledb-connection-string-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!