现在我有一段程序是读取excel文件 用的是OLEDB,但是在64位机器下会报一个错误。
The 'Microsoft.Jet.OLEDB.12.0' provider is not registered on the local machine.我的环境是win7(64)+VS2008+Office2007
在编译时将环境改为x86还是不行,网上说是因为64位机器不支持32位的provider。跪求解决办法。
代码片段:using System.Data.OleDb; private DataSet readExcel(string excelpath)
{
DataSet ds = null;
try
{
string strconn = String.Format("Provider=Microsoft.Jet.OLEDB.12.0; Data Source={0}; Extended Properties =Excel 12.0;", excelpath);
OleDbConnection conn = new OleDbConnection(strconn);
conn.Open();
string strexcel = "";
OleDbDataAdapter mycommand = null;
strexcel = "select * from [sheet1$]";
mycommand = new OleDbDataAdapter(strexcel, strconn);
ds = new DataSet();
mycommand.Fill(ds, "table1");
}
catch (Exception e)
{
this.mResult.AppendText(e.Message.ToString() + "\r\n");
}
return ds;
}
The 'Microsoft.Jet.OLEDB.12.0' provider is not registered on the local machine.我的环境是win7(64)+VS2008+Office2007
在编译时将环境改为x86还是不行,网上说是因为64位机器不支持32位的provider。跪求解决办法。
代码片段:using System.Data.OleDb; private DataSet readExcel(string excelpath)
{
DataSet ds = null;
try
{
string strconn = String.Format("Provider=Microsoft.Jet.OLEDB.12.0; Data Source={0}; Extended Properties =Excel 12.0;", excelpath);
OleDbConnection conn = new OleDbConnection(strconn);
conn.Open();
string strexcel = "";
OleDbDataAdapter mycommand = null;
strexcel = "select * from [sheet1$]";
mycommand = new OleDbDataAdapter(strexcel, strconn);
ds = new DataSet();
mycommand.Fill(ds, "table1");
}
catch (Exception e)
{
this.mResult.AppendText(e.Message.ToString() + "\r\n");
}
return ds;
}
解决方案 »
- WinForms中下载图片问题
- 用linq 获取字典value为最大的那条数据,包含key和value,该怎么做
- c#调用VC++6.0的DLL出错
- 关于winform层序打包的问题
- dataGrid如何根据表中两列值的大小来确定某一项是否显示?
- 关于crystal reports的疑难问题。。
- GUI程序中用了System.Console.Out.Write()如何察看他的输出。
- [WPF]关于MemoryStream在子线程中操作报ArgumentException异常的问题
- 请问windows程序中的“停靠和浮动工具栏”如何在.net中C#实现
- 500RMB买个技术,难道没有人能解决吗?
- 水晶报表打印及小数格式问题,请教各位!
- 怎么实现先播放声音,一段时间后再迁移窗体?
string strconn ="
Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\";"
http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/b70a8fe1-4253-4043-a9c0-98b4e369821c