怎么动态调用不同的 reporting service报表
如何动态调用不同的 reporting service报表
我设计了两个报表,分别为bdz_01.rdlc,bdz_02.rdlc
Dim constr As String = "server=192.168.0.66;database=zjc_netconfer;user id=zjc_bingo;password=zsjyc; "
Dim sqlstr As String = "select * from print_bdz where student_no= ' " + TextBox1.Text.ToString.Trim + " ' "
Dim objconn As New SqlConnection(constr)
Dim objAdapter As New SqlDataAdapter(sqlstr, objconn)
Dim objdataset As New DataSet
objAdapter.Fill(objdataset)
If objdataset.Tables(0).Rows.Count = 0 Then
MessageBox.Show( "没有你所查询的内容! ")
TextBox1.Clear()
Else
Me.ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource( "ZJC_NETCONFERDataSet_Print_bdz ", objdataset.Tables(0)))
Me.ReportViewer1.RefreshReport()
End If
上面的代码只能调用一个在ReportViewer1中选定好的报表,我现在选定的是bdz_01.rdlc。
我想实现的是根据条件的不同,我可以调用这两个报表,在ReportViewer1中显示。
请教各位高手了。谢谢。
------解决方案--------------------
你可以将ReportViewer作为变量。
private function1 (byval rv as ReportViewer)
------解决方案--------------------
Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "XXXXXXX.bjcx.rdlc "
Me.ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource( "bjcx_DataSet_View_result_class ", load_class_result(c_id)))
其中 ReportEmbeddedResource 可以用来 指定rdlc的文件名称
但是有一个问题 文件名是 bjcx.rdlc 你要在前边 加上 项目名称 XXXXXXX
如果我不加的话 在测试的时候 就会找不到
还有另外一个问题
bjcx.rdlc的属性有一个 生成操作 应该是 嵌入的资源 就是说应该包含在exe里边的
但是我的策划那个需经常找不到bjcx.rdlc 也就是说他没有包含进取
如果涅解决了这2个问题 麻烦告诉我一下 xiaobingking@126.com
------解决方案--------------------
直接将资源添加到项目中,然后属性设为嵌入资源不就行了
下次编译资源就被嵌入了,可以使用对象浏览器查看到的
我设计了两个报表,分别为bdz_01.rdlc,bdz_02.rdlc
Dim constr As String = "server=192.168.0.66;database=zjc_netconfer;user id=zjc_bingo;password=zsjyc; "
Dim sqlstr As String = "select * from print_bdz where student_no= ' " + TextBox1.Text.ToString.Trim + " ' "
Dim objconn As New SqlConnection(constr)
Dim objAdapter As New SqlDataAdapter(sqlstr, objconn)
Dim objdataset As New DataSet
objAdapter.Fill(objdataset)
If objdataset.Tables(0).Rows.Count = 0 Then
MessageBox.Show( "没有你所查询的内容! ")
TextBox1.Clear()
Else
Me.ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource( "ZJC_NETCONFERDataSet_Print_bdz ", objdataset.Tables(0)))
Me.ReportViewer1.RefreshReport()
End If
上面的代码只能调用一个在ReportViewer1中选定好的报表,我现在选定的是bdz_01.rdlc。
我想实现的是根据条件的不同,我可以调用这两个报表,在ReportViewer1中显示。
请教各位高手了。谢谢。
------解决方案--------------------
你可以将ReportViewer作为变量。
private function1 (byval rv as ReportViewer)
------解决方案--------------------
Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "XXXXXXX.bjcx.rdlc "
Me.ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource( "bjcx_DataSet_View_result_class ", load_class_result(c_id)))
其中 ReportEmbeddedResource 可以用来 指定rdlc的文件名称
但是有一个问题 文件名是 bjcx.rdlc 你要在前边 加上 项目名称 XXXXXXX
如果我不加的话 在测试的时候 就会找不到
还有另外一个问题
bjcx.rdlc的属性有一个 生成操作 应该是 嵌入的资源 就是说应该包含在exe里边的
但是我的策划那个需经常找不到bjcx.rdlc 也就是说他没有包含进取
如果涅解决了这2个问题 麻烦告诉我一下 xiaobingking@126.com
------解决方案--------------------
直接将资源添加到项目中,然后属性设为嵌入资源不就行了
下次编译资源就被嵌入了,可以使用对象浏览器查看到的