找回密码
 立即注册

QQ登录

只需一步,快速开始

gabong414

新手上路

1

主题

1

帖子

21

积分

新手上路

积分
21
  • 20

    金币

  • 主题

  • 帖子

最新发帖
gabong414
新手上路   /  发表于:2014-5-23 14:13  /   查看:4660  /  回复:2
active reports8中,数据源配置是否只能通过报表资源管理器中添加数据源进行配置?若系统服务器更换后,是否只能在报表资源管理器中修改连接字符串?是否有其他方法?

2 个回复

倒序浏览
roger.wang
社区贡献组   /  发表于:2014-5-23 15:24:00
沙发
您好,您的问题解答如下:
报表资源管理器中的数据源,是为了快速在开发环境下设计出报表来,实际项目部署后,数据源可灵活切换(表结构、字段相同)

这里有源码供您参考:

  1. private void btnDataSet_Click(object sender, System.EventArgs e)
  2.                 {
  3.                         this.Cursor = Cursors.WaitCursor;
  4.                         //Dataset to hold data.
  5.                         DataSet _InvoiceData = new DataSet();
  6.                         _InvoiceData.Locale = CultureInfo.InvariantCulture;
  7.                         //Database connection populated from the sample Northwind access database
  8.             OleDbConnection _nwindConn = new OleDbConnection();
  9.             _nwindConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\rogerwang\\Documents\\ComponentOne Samples\\ActiveReports 8\\Data\\NWIND.MDB;Persist Security Info=False";
  10.                         //Run the SQL command.
  11.                         OleDbCommand _selectCMD = new OleDbCommand("SELECT * FROM Invoices ORDER BY Customers.CompanyName, OrderID", _nwindConn);
  12.                         _selectCMD.CommandTimeout = 30;
  13.                         //Data adapter used to run the select command
  14.                         OleDbDataAdapter _InvoicesDA = new OleDbDataAdapter();
  15.                         _InvoicesDA.SelectCommand = _selectCMD;
  16.                         //Fill the DataSet.
  17.                         _InvoicesDA.Fill(_InvoiceData, "Invoices");
  18.                         //Create the report and assign the data source.
  19.                         Invoice rpt = new Invoice();
  20.                         rpt.DataSource = _InvoiceData;
  21.                         rpt.DataMember = _InvoiceData.Tables[0].TableName;
  22.             arvMain.Document = new ActiveReports.Document.SectionDocument();
  23.                         //Run and view the report.
  24.                         rpt.Run(false);
  25.                         arvMain.Document = rpt.Document;
  26.                         this.Cursor = Cursors.Arrow;
  27.                 }
复制代码


更多源码,请参考安装AR8后自带的5个数据源的示例:
C:\Users\rogerwang\Documents\ComponentOne Samples\ActiveReports 8\Section Reports\C#\Data
回复 使用道具 举报
roger.wang
社区贡献组   /  发表于:2014-6-9 09:12:00
板凳
欢迎有问题开新帖沟通。
   

回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部