Click here to Skip to main content
15,887,338 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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
Posted
Updated 14-Dec-18 1:24am

1 solution

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:
VB
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900