C
C a r l o s A n t o n i o
Hello,
I have an ASP.NET application that contains reports. I am not allowed to
use Crystal, so I decided to use .NET's reporting tool. My problem is that
the report viewer does not show in the browser, neither I am receiving any
error messages. Below is the code. Any help will be really appreciated.
Thank you very much for your help.
Carlos
Private Sub Show_Report(ByVal From_rpt_date As Date, ByVal To_rpt_date
As Date)
'Set the processing mode for the ReportViewer to Local
ReportViewer1.Reset()
ReportViewer1.ProcessingMode =
Microsoft.Reporting.WebForms.ProcessingMode.Local
ReportViewer1.Visible = True
Dim LocalRpt As New Microsoft.Reporting.WebForms.LocalReport
LocalRpt.ReportPath = "~/MyReport.rdlc"
'name of connection string as stored in web.config
Dim s_connString As String = "MyConnString"
Dim cn As New
SqlConnection(ConfigurationManager.ConnectionStrings(s_connString).ConnectionString)
' "MyStoredProcedure" is the name of the stored procedure
Dim cmd As New SqlCommand("MyStoredProcedure", cn)
cmd.CommandType = Data.CommandType.StoredProcedure
' "@from_eff_date" and "@to_eff_date" are the names of
'Stored procedure parameters
cmd.Parameters.Add("@from_eff_date", Data.SqlDbType.DateTime).Value
= From_rpt_date
cmd.Parameters.Add("@to_eff_date", Data.SqlDbType.DateTime).Value =
To_rpt_date
cmd.CommandTimeout = 120
'declare and configure SqlDataAdapter
Dim da As New SqlDataAdapter
da.SelectCommand = cmd
' MyDataSet is the name of the DataSet
Dim ds As New MyDataSet
da.Fill(ds, "MyDataTable")
' "MyDataTable" is the name of the DataTable
Dim rds As New Microsoft.Reporting.WebForms.ReportDataSource
rds.Name = "MyDataTable"
rds.Value = ds.Tables("MyDataTable")
' Add ReportDataSource to Local
LocalRpt.DataSources.Add(rds)
LocalRpt.Refresh()
End Sub
I have an ASP.NET application that contains reports. I am not allowed to
use Crystal, so I decided to use .NET's reporting tool. My problem is that
the report viewer does not show in the browser, neither I am receiving any
error messages. Below is the code. Any help will be really appreciated.
Thank you very much for your help.
Carlos
Private Sub Show_Report(ByVal From_rpt_date As Date, ByVal To_rpt_date
As Date)
'Set the processing mode for the ReportViewer to Local
ReportViewer1.Reset()
ReportViewer1.ProcessingMode =
Microsoft.Reporting.WebForms.ProcessingMode.Local
ReportViewer1.Visible = True
Dim LocalRpt As New Microsoft.Reporting.WebForms.LocalReport
LocalRpt.ReportPath = "~/MyReport.rdlc"
'name of connection string as stored in web.config
Dim s_connString As String = "MyConnString"
Dim cn As New
SqlConnection(ConfigurationManager.ConnectionStrings(s_connString).ConnectionString)
' "MyStoredProcedure" is the name of the stored procedure
Dim cmd As New SqlCommand("MyStoredProcedure", cn)
cmd.CommandType = Data.CommandType.StoredProcedure
' "@from_eff_date" and "@to_eff_date" are the names of
'Stored procedure parameters
cmd.Parameters.Add("@from_eff_date", Data.SqlDbType.DateTime).Value
= From_rpt_date
cmd.Parameters.Add("@to_eff_date", Data.SqlDbType.DateTime).Value =
To_rpt_date
cmd.CommandTimeout = 120
'declare and configure SqlDataAdapter
Dim da As New SqlDataAdapter
da.SelectCommand = cmd
' MyDataSet is the name of the DataSet
Dim ds As New MyDataSet
da.Fill(ds, "MyDataTable")
' "MyDataTable" is the name of the DataTable
Dim rds As New Microsoft.Reporting.WebForms.ReportDataSource
rds.Name = "MyDataTable"
rds.Value = ds.Tables("MyDataTable")
' Add ReportDataSource to Local
LocalRpt.DataSources.Add(rds)
LocalRpt.Refresh()
End Sub