本帖最后由 Lenka.Guo 于 2016-3-7 16:17 编辑
我修改的实例代码需要连接SQL,修改后还是没有连接成功报错误:GrapeCity.ActiveReports.ReportException”类型的异常在 GrapeCity.ActiveReports.v10.dll 中发生,但未在用户代码中进行处理
其他信息: 发生了一个意外错误。更多信息: 'No data provider found for the data provider type 'SQLOLEDB'.'
代码:
// Provide the page report you want to render.
GrapeCity.ActiveReports.PageReport _reportDef = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath("~/Reports/" + report + ".rdlx")));
_reportDef.Report.DataSources[0].DataSourceReference = "";
_reportDef.Report.DataSources[0].ConnectionProperties.DataProvider = "SQLOLEDB";
_reportDef.Report.DataSources[0].ConnectionProperties.ConnectString = @"user id=sa;data source=(local);initial catalog=报表测试数据库;password=123456;";
GrapeCity.ActiveReports.Document.PageDocument _reportRuntime = new GrapeCity.ActiveReports.Document.PageDocument(_reportDef);
// Create an output directory
System.IO.MemoryStream ms = new System.IO.MemoryStream();
// Provide settings for your rendering output.
GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings
excelSetting = new GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings();
excelSetting.FileFormat = GrapeCity.ActiveReports.Export.Excel.Page.FileFormat.Xls;
GrapeCity.ActiveReports.Extensibility.Rendering.ISettings setting = excelSetting;
//Set the rendering extension and render the report.
GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension
excelRenderingExtension = new
GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension();
GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider();
_reportRuntime.Render(excelRenderingExtension, outputProvider, excelSetting.GetSettings());
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("content-disposition", "inline;filename=客户订单.xls");
outputProvider.GetPrimaryStream().OpenStream().CopyTo(ms);
Response.BinaryWrite(ms.ToArray());
Response.End();
|
|