fizsoft 发表于 2015-7-30 15:59:00

数据源类型问题

我从社区下载了DynamicParameters的那个例子,其中有一段导出Excel文件的代码:

string report = "RdlReport2";
GrapeCity.ActiveReports.PageReport _reportDef = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath("/Reports/" + report + ".rdlx")));
_reportDef.Report.DataSources.DataSourceReference = "";
_reportDef.Report.DataSources.ConnectionProperties.DataProvider = "OLEDB";
_reportDef.Report.DataSources.ConnectionProperties.ConnectString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};", Server.MapPath("/Data/NWind_CHS.mdb"));

我的问题是第4行DataSources.ConnectionProperties.DataProvider这个属性除了OLEDB,其他类型的怎么写,我需要SqlClient型和Oracle的,但是试了很多种写法都不行,文档中也没有。

fizsoft 发表于 2015-7-30 16:09:00

还有我如果指定DataSourceReference到一个rdsx文件,是不是ConnectionProperties.DataProvider和ConnectionProperties.ConnectString就不用赋值了。

求解答,谢谢

frank.zhang 发表于 2015-7-30 17:21:00

您好,
通常来说,只有Access数据库需要指定数据源,因为Access数据源是有具体的位置的。
SqlClient只是在设计时指定就可以了。



当然,代码也可以,但是不推荐使用
_reportDef.Report.DataSources.ConnectionProperties.DataProvider 为 "SQL";
_reportDef.Report.DataSources.ConnectionProperties.ConnectString 为 "data source=.;initial catalog=TEST;user id=sa;";

_reportDef.Report.DataSources.ConnectionProperties.DataProvider 为 "ORACLE";
_reportDef.Report.DataSources.ConnectionProperties.ConnectString 为 "User Id=scott;Password=tiger;Data Source=127.0.0.1;";

frank.zhang 发表于 2015-8-7 17:39:00

为了给你提供更优质的服务,请对本次服务进行评分。我们会认真对待你提出的宝贵意见,谢谢
http://gcdn.gcpowertools.com.cn/attachment.aspx?attachmentid=10062
页: [1]
查看完整版本: 数据源类型问题