报告查看器参数丢失 - 如何解决此问题? [英] Report viewer parameter missing- how can I solve this?

查看:90
本文介绍了报告查看器参数丢失 - 如何解决此问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Private Sub ReportViewer1_Load(sender as Object,e As EventArgs)处理ReportViewer1.Load



尝试







如果cn.State = ConnectionState.Closed那么

cn.Open()

结束如果



如果cn.State<> ConnectionState.Open然后

MsgBox(数据库连接错误,MsgBoxStyle.Information)

Me.Close()



结束如果



ds.Reset()

str =select * from TabSales

cmd =新的SqlCommand(str,cn)

da.SelectCommand = cmd

da.Fill(ds)

da.Dispose()

cmd.Dispose()

cn.Close()





昏暗rds = New ReportDataSource(dsSales,ds.Tables(0))

MsgBox(ds.Tables(0,1))

ReportViewer1.LocalReport.ReportEmbeddedResource = Harsha_Bill.Invoice.rdlc

ReportViewer1.LocalReport.DataSources.Clear()

ReportViewer1.LocalReport.DataSources.Add(rds)

ReportViewer1 .RefreshReport()





Catch ex As Exception

MessageBox.Show(ex.Message,My.Application.Info.Title,MessageBoxButtons.OK,MessageBoxIcon。错误)

结束尝试

结束次级





结束类



我尝试了什么:



我对RDLC非常陌生,而且我找不到问题在哪里

Private Sub ReportViewer1_Load(sender As Object, e As EventArgs) Handles ReportViewer1.Load

Try



If cn.State = ConnectionState.Closed Then
cn.Open()
End If

If cn.State <> ConnectionState.Open Then
MsgBox("Database Connectivity Error", MsgBoxStyle.Information)
Me.Close()

End If

ds.Reset()
str = "select * from TabSales"
cmd = New SqlCommand(str, cn)
da.SelectCommand = cmd
da.Fill(ds)
da.Dispose()
cmd.Dispose()
cn.Close()


Dim rds = New ReportDataSource("dsSales", ds.Tables(0))
MsgBox(ds.Tables(0, 1))
ReportViewer1.LocalReport.ReportEmbeddedResource = "Harsha_Bill.Invoice.rdlc"
ReportViewer1.LocalReport.DataSources.Clear()
ReportViewer1.LocalReport.DataSources.Add(rds)
ReportViewer1.RefreshReport()


Catch ex As Exception
MessageBox.Show(ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub


End Class

What I have tried:

I am very New to RDLC, And I cant Found Where is the Problem

推荐答案

猜测,这是源名称:我怀疑dsSales不是表格中数据的名称。试试这个:

At a guess, it's the source name: I suspect that "dsSales" is not the name of the data in the table itself. Try this:
Dim dt as DataTable = ds.Tables(0);
Dim rds = new ReportDataSource(dt.TableName, dt)



我还强烈建议您使用使用块,而不是手动关闭和处理 - 这样,即使出现错误系统将在你之后清理。


I would also strongly suggest that you use Using blocks, instead of manually closing and disposing - that way, even if there is an error the system will clear up after you.


这篇关于报告查看器参数丢失 - 如何解决此问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆