找回密码
 立即注册

QQ登录

只需一步,快速开始

fizsoft

注册会员

16

主题

44

帖子

140

积分

注册会员

积分
140

活字格认证微信认证勋章

[已处理] 数据源类型问题

fizsoft
注册会员   /  发表于:2015-7-30 15:59  /   查看:3933  /  回复:3
我从社区下载了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[0].DataSourceReference = "";
_reportDef.Report.DataSources[0].ConnectionProperties.DataProvider = "OLEDB";
_reportDef.Report.DataSources[0].ConnectionProperties.ConnectString = string.Format(&quotrovider=Microsoft.Jet.OLEDB.4.0;Data Source={0};", Server.MapPath("/Data/NWind_CHS.mdb"));

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

3 个回复

倒序浏览
fizsoft
注册会员   /  发表于:2015-7-30 16:09:00
沙发
还有我如果指定DataSourceReference到一个rdsx文件,是不是ConnectionProperties.DataProvider和ConnectionProperties.ConnectString就不用赋值了。

求解答,谢谢
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-7-30 17:21:00
板凳
您好,
通常来说,只有Access数据库需要指定数据源,因为Access数据源是有具体的位置的。
SqlClient只是在设计时指定就可以了。



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

  1. _reportDef.Report.DataSources[0].ConnectionProperties.DataProvider 为 "ORACLE";
  2. _reportDef.Report.DataSources[0].ConnectionProperties.ConnectString 为 "User Id=scott;Password=tiger;Data Source=127.0.0.1;";
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复 使用道具 举报
frank.zhang
社区贡献组   /  发表于:2015-8-7 17:39:00
地板
为了给你提供更优质的服务,请对本次服务进行评分。我们会认真对待你提出的宝贵意见,谢谢
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部