Question How to display the rows and columns generated by SQL query in rdlc report dynamically

nixdaemon000

New member
Joined
Dec 15, 2008
Messages
4
Programming Experience
Beginner
How to display the rows and columns generated by SQL query in rdlc report dynamically.

Before i created the .rdlc file and then add tables and then Column Names to display. Now i dont want to design the .rdlc file and i wanted to fill the .rdlc file with the number of columns and rows returned by SQL Server.
Can anyone give me idea how to do it? I am using the code like this as shown below.

VB.NET:
Dim strQry = "select CompanyName,Address,Address1,City,State,Zip,Telephone,Email from Company"
        Dim reportPath = "MyReportApplication.reportCompany.rdlc"
        Dim sReportDataSource As ReportDataSource
        Connection()
        OpenConn()
        ds = New DataSet()
        dataAdapter = New SqlDataAdapter(strQry, conn)
        dataAdapter.Fill(ds, "TestDataBase")
        rdlcViewer.LocalReport.ReportEmbeddedResource = reportPath
        sReportDataSource = New ReportDataSource()
        sReportDataSource.Name = "TestDB_Company"
        sReportDataSource.Value = ds.Tables(0)
        rdlcViewer.LocalReport.DataSources.Add(sReportDataSource)
        rdlcViewer.Dock = DockStyle.Fill
        CloseConn()
        Me.rdlcViewer.RefreshReport()
 
Back
Top