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?
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?