FastReport报表 不保存连接信息时使用多表数据源(代码)
来源:互联网 发布:windows寨板 哪款好 编辑:程序博客网 时间:2024/06/05 09:06
今天做的报表涉及到一个报表里使用3个数据表,如何将这三个表的数据映射到fastreport中呢,看下面代码。对应的要在fastreport中将表改成这个名字,数据库连接信息就可以不用保存到报表中了。
btnExportBargain.Enabled = false; int paperId = Convert.ToInt32(ucDataGridView1.Rows[ucDataGridView1.CurrentRow.Index].Cells[0].Value.ToString()); string conStr = BaseSystemInfo.ConnectionString; try { SqlConnection con = new SqlConnection(conStr); con.Open(); SqlCommand sqlcmd = new SqlCommand(); sqlcmd.Connection = con; sqlcmd.CommandText = "select * from [VW_报表打印] where Id=" + paperId+"; select * from VW_报表打印_详细记录 where 询价单id=" + paperId + "; select * from VW_报表打印_详细记录 where 询价单id=" + paperId + " and 是否采用=1";;; SqlDataAdapter sda = new SqlDataAdapter(sqlcmd); sda.TableMappings.Add("Table", "Table"); sda.TableMappings.Add("Table1", "T2"); sda.TableMappings.Add("Table2", "T3"); ds1 = new DataSet(); sda.Fill(ds1); con.Close(); sda.Dispose(); } catch (Exception err) { MessageBox.Show(err.StackTrace); } try { FastReport.Report report = new FastReport.Report(); string filename = @"D:\12.合同商定记录.frx"; report.Load(filename); report.RegisterData(ds1); report.GetDataSource("Table").Enabled = true; report.GetDataSource("T2").Enabled = true; report.GetDataSource("T3").Enabled = true; report.Show(); } catch (Exception err) { MessageBox.Show(err.Message); } btnExportBargain.Enabled = true;
0 0
- FastReport报表 不保存连接信息时使用多表数据源(代码)
- 使用fastreport以代码方式创建报表
- FastReport.Net中使用列表和数组作为报表数据源
- FastReport.Net报表中使用 Excel 文件作为数据源
- 使用FastReport Studio开发报表(一)
- 使用FastReport Studio开发报表(二)
- 使用FastReport Studio开发报表(三)
- 使用FastReport Studio开发报表(四)
- 使用FastReport Studio开发报表(一)
- JAVA连接ACCESS(不使用数据源)
- FastReport.Net 报表连接数据库
- 使用JDBC-ODBC方式连接数据库时,如何在代码中指定ODBC数据源信息
- 报表操作(FastReport)
- delphi xe2报表控件fastreport使用时出错的解决
- C#使用FastReport 报表初步体验(图文)
- FastReport报表 设计复杂报表使用子报表解决(图文)
- Delphi报表(QuickReport & FastReport)
- Delphi报表(QuickReport & FastReport)
- Didn't find class "...l" on path: DexPathList
- MySQL乱码问题
- 李飞飞:斯坦福AI实验室图像与视觉理解技术进展
- ALV的layout属性
- 【Android学习笔记】AndroidStudio报Error:Execution failed for task ':app:buildInfoDebugLoader'.
- FastReport报表 不保存连接信息时使用多表数据源(代码)
- PT、CT、CVT各是什么意思?
- HDU-1316 How Many Fibs?(Java大数)
- Android Matrix详解
- 关于jdk安装问题
- Android ScrollView 嵌套 ScrollView 滑动
- Swift语法13:类的构造函数
- 例题:蛇形填数
- java集合框架系列---fail-fast机制