Reporting Services Questions

C

checkraiser

I am trying to take an .RDLC report that I created in Visual Studio 2008 and
bind it to a data table.

I created this code to pull the datatable--I am using an IBM Data Provider
for .NET, pulling the data from a System i/DB2 DB--which works. I've
confirmed that the data table is being created with data. Code below:

public DataTable getMyTransactionData()
{
DataTable dtCustomers = new DataTable("Trans");
try
{ using (iDB2Connection cnn = new
iDB2Connection(ConfigurationManager.ConnectionStrings["DB2ConnectionString"].ConnectionString) )
{
iDB2Command cmd = new iDB2Command();
cmd.Connection = cnn;
cmd.CommandText = "Select A.Offer, A.EventDate from
Event";

// open connection
cnn.Open();

//create data adapter and table.
iDB2DataAdapter da = new
iDB2DataAdapter(cmd.CommandText,cnn);

//fill datatable with data
da.Fill(dtCustomers);

// close connection
cnn.Close();
}

}

catch (iDB2Exception iex)
{
throw (iex);
}
catch (Exception ex)
{
throw(ex);
}

return dtCustomers;

}

I have a page with a ReportViewer which I bind the datatable to my RLDC file
in:

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DataTable dt;
MyTransaction objTRN = new MyTransaction();
dt = objTRN.getMyTransactionData();
ReportDataSource rds = new ReportDataSource();
rds.Name = "Trans";
rds.Value = dt;
ReportViewer1.LocalReport.DataSources.Add(rds);
//ReportViewer1.LocalReport.Refresh();
}
}

My questions:

1.) The report RLDC file already has a prior, old datasource specified in
it's XML with different field definitions. The old datasource is specified
at the table level as well as for the report's datasource. How do I change
this datasource designation for the datatable I'm querying above and remove
the existing datasource/field designations, as well as autogenerate all the
XML field definitions for my table in the RLDC?

2.) On another report, I noticed that ReportViewer1.LocalReport.Refresh();
was required in order to get the report to generate. Is it possible to stop
the report from auto loading on page load?
 
A

Allen Chen [MSFT]

Hi,
1.) The report RLDC file already has a prior, old datasource specified in
it's XML with different field definitions. The old datasource is specified
at the table level as well as for the report's datasource. How do I change
this datasource designation for the datatable I'm querying above and remove
the existing datasource/field designations, as well as autogenerate all the
XML field definitions for my table in the RLDC?

As far as I know there's no auto way to generate RDLC file. You probably
can create a RDLC file beforehand to serve your report. Please open the
existing .rdlc file in notepad and you would be able to figure out how to
customize the report.

As to changing datasource, you can change DataSourceId of ReportDataSource
to use another ObjectDataSource. ReportPath of LocalReport also need to be
changed to use the new RDLC file.

2.) On another report, I noticed that
ReportViewer1.LocalReport.Refresh();
was required in order to get the report to generate. Is it possible to stop
the report from auto loading on page load?

Do you mean on first page load you don't want to see any report? To do so
you can try something like this:

aspx:

<asp:Button ID="Button1" runat="server" Text="Button"
onclick="Button1_Click" />
<rsweb:ReportViewer ID="ReportViewer1" runat="server"
Font-Names="Verdana"
Font-Size="8pt" Height="400px" Width="400px">

</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetData"

TypeName="WebApplication22.NorthwindDataSetTableAdapters.CustomersTableAdapt
er">
</asp:ObjectDataSource>

aspx.cs:

protected void Button1_Click(object sender, EventArgs e)
{
// render report
this.ReportViewer1.LocalReport.ReportPath = "Report1.rdlc";
this.ReportViewer1.LocalReport.DataSources.Add(new
ReportDataSource("NorthwindDataSet_Customers","ObjectDataSource1"));
}

Please have a try and let me know if it works.

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

Allen Chen [MSFT]

Hi,
1.) The report RLDC file already has a prior, old datasource specified in
it's XML with different field definitions. The old datasource is specified
at the table level as well as for the report's datasource. How do I change
this datasource designation for the datatable I'm querying above and remove
the existing datasource/field designations, as well as autogenerate all the
XML field definitions for my table in the RLDC?

Do you have any progress on this issue? If you have further questions
please don't hesitate to let me know. I'll do my best to follow up.


Regards,
Allen Chen
Microsoft Online Support
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,931
Messages
2,570,085
Members
46,536
Latest member
keelop

Latest Threads

Top