SQL Server table export to Excel issue
I am using 64-bit Windows Server 2008 with SQL Server 2008. And Using VS2008 + C# + .Net 2.0 + IIS 7.0 + ASP.Net. When executing the following statement, I met with the following error (the error occurs when accessing an aspx page), I am not sure wheth开发者_运维知识库er it is 64-bit system specific issue?
Sys.WebForms.PageRequestManagerServerErrorException: unregistered OLE DB access interface "Microsoft.Jet.OLEDB.4.0"
StringBuilder sb = new StringBuilder();
sb.AppendLine("select * from OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 8.0;HDR=YES;DATABASE=" + s_path.Trim() + "',sheet1$) where name is not null"); //e:\\test1.xls
DataSet ds = SqlUtil.ExecuteDataset(Database.StrConn, CommandType.Text, sb.ToString());
if (ds.Tables[0].Rows.Count > 0)
{
GridView_Tlinkmans.DataSource = ds;
GridView_Tlinkmans.DataBind();
}
You have one or 2 issues:
You are querying OPENROWSET in SQL Server and you have x64 SQL Server, you may need the MDAC to bridge SQL Server to ODBC/OLEDB. However, this says it is part of the OS for Win 2008+. I've had to install on Win 2003
Then you probably need this which is the closest to JET I know of: Microsoft Access Database Engine 2010 Redistributable
YMMV
精彩评论