arnold_p
arnold_p

Reputation: 505

ReportViewer did not display data

I have tried to add report using ReportViewer in Visual Studio 2012, SQL Server 2005. I am using Visual Basic Language.

So far I've tried this code and did not show the data I wanted

Imports Microsoft.Reporting.WinForms
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim rds As New ReportDataSource("DataSet1")

    Me.ReportViewer1.LocalReport.ReportPath = "C:\Users\acer\Documents\Visual Studio 2012\Projects\WindowsApplication1\WindowsApplication1\Report1.rdlc"
    Me.ReportViewer1.LocalReport.DataSources.Clear()
    Me.ReportViewer1.LocalReport.DataSources.Add(rds)
    Me.ReportViewer1.RefreshReport()
End Sub
End Class

Can anybody show me how to fix this? Thanks a lot

Upvotes: 1

Views: 2462

Answers (2)

shubhankar
shubhankar

Reputation: 1

Again Configuration of Datasource and reportview .Firstly go to ADD Datasoure then select database then click the next then select dataset then click next again next then check both tables and Views then Finish ... then select report view then click new design then finish then choose report then hope so enter image description here

Upvotes: 0

ɐsɹǝʌ ǝɔıʌ
ɐsɹǝʌ ǝɔıʌ

Reputation: 4512

Supossing that your DataSet contains one or more DataTables, you're missing the DataTable which you want to show on the report.

Dim rds As New ReportDataSource("DataSet1", ds.Tables(0))

From what I see in your code, you don't have any DataTable neither any source where you're retrieving data from. The below code shows how to retrieve data from a database table and display it onto your ReportViewer

Dim strConnectionString As String = "Your connection string here"
Dim ds As New DataSet()
Dim da As New SqlDataAdapter()
Dim cmd As New SqlCommand("SELECT * FROM YourTable")
cmd.CommandType = CommandType.Text
cmd.Connection = New SqlConnection(strConnectionString)
da.SelectCommand = cmd

da.Fill(ds, "DataSet1")

Dim rds As New ReportDataSource("DataSet1", ds.Tables(0))

Me.ReportViewer1.LocalReport.ReportPath = "C:\Users\acer\Documents\Visual Studio 2012\Projects\WindowsApplication1\WindowsApplication1\Report1.rdlc"
Me.ReportViewer1.LocalReport.DataSources.Clear()
Me.ReportViewer1.LocalReport.DataSources.Add(rds)
Me.ReportViewer1.RefreshReport()

Upvotes: 1

Related Questions