C#读取Excel The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the loc
在服务器调试的时候,读取Excel没有问题,但是一旦发布,就不行了。
报错:The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine.
我觉得是不是应用池环境和 Visual Web Developer Web Server测试环境不同的问题?
我的环境是XP+Visual Studio 2005.
不知道该怎么设置IIS.
代码:
DataSet ds = null;
string strconn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + savefilepath + ";" + "Extended Properties='Excel 8.0;HDR=NO;IMEX=1;'";
OleDbConnection conn = new OleDbConnection(strconn);
try
{
conn.Open();
OleDbDataAdapter myCommand = new OleDbDataAdapter("select * from [Sheet1$]", strconn);
ds = new DataSet();
myCommand.Fill(ds, "[sheet1$]");
EUCnameTextBox.Text = ds.Tables[0].Rows[6][1].ToString();
}
finally
{
conn.Close();
}