i want to generate an
ondemand SubReport against each row of a particular field in the MainReport i.e. clicking each ondemand SubReport link will generate a corresponding row of data in the same form(but new report document)
The data for the MainReport n SubReport are called via get_receivedData Storedprocs using
refcursors, from two different tables in the database under two different packages. I've written n compiled the Storedprocs successfully(both similar except parameternames). I can also view The data in the MainReport succesfully in my Webform1.aspx. But while clicking on any of the subreport ondemand links errors/exceptions occur occur. At first there was an error
"Logon failed. Error in File CrystalReport_More {E5618E1D-3141-47D1-9058-8D7CF11B6AE2}.rpt:Unable to connect to database: Incorrect logon Parameters error"
When i set breakpoints in my subReport method
public DataTable getSubOrders(int id)
{
try
{
if (Con.State != ConnectionState.Open)
{
Con.Open();
}
ReportDocument subreport = new ReportDocument();
cmd.Parameters.Clear();
cmd.CommandText = "pkg_test_MORE.sp_get_received_data_MORE";
cmd.CommandType = CommandType.StoredProcedure;
OracleParameter Para_ID = new OracleParameter("Temp_id", OracleDbType.Int32);
OracleParameter Para_RSCUR = new OracleParameter("nreturned", OracleDbType.RefCursor);
Para_ID.Direction = ParameterDirection.Input;
Para_ID.Value = id;
Para_RSCUR.Direction = ParameterDirection.Output;
cmd.Parameters.Add(Para_ID);
cmd.Parameters.Add(Para_RSCUR);
OracleDataAdapter adapter = new OracleDataAdapter(cmd);
string MORE_DETAILS = ds.Tables[0].TableName;
adapter.Fill(ds, "MORE_DETAILS");
DataRow moreDetailsRow;
foreach (DataRow row in ds10.Tables["MORE_DETAILS"].Rows)
{
moreDetailsRow = ds10.Tables["MORE_DETAILS"].NewRow();
moreDetailsRow["RNK"] = Convert.ToInt32(row["RNK"].ToString());
moreDetailsRow["TITLE"] = row["TITLE"].ToString();
moreDetailsRow["CAST1"] = row["CAST1"].ToString();
moreDetailsRow["RATED"] = Convert.ToInt32(row["RATED"].ToString());
moreDetailsRow["PROFIT"] = Convert.ToInt32(row["PROFIT"].ToString());
ds10.Tables["MORE_DETAILS"].Rows.Add(moreDetailsRow);
}
ds.Tables["MORE_DETAILS"].AcceptChanges();
subreport.Load(HttpContext.Current.Server.MapPath("~/Reports/CrystalReport3.rpt"));
subreport.SetDataSource(ds10.Tables["MORE_DETAILS"]);
CrystalReportViewer3.ReportSource = subreport;
CrystalReportViewer3.DataBind();
cmd.Dispose();
if (Con.State != ConnectionState.Closed)
Con.Close();
return ds.Tables["MORE_DETAILS"];
}
catch (OracleException ex)
{
Response.Write(ex.ToString());
return null;
}
}
NullReference Exception Unhandled by the user code: "Object reference not set to an instance of an object." message is shown.
Following is the code for my Page_load method n the method for receiving data from database for my MainReport...
(all of the remaining code actually)
public partial class WebForm1 : System.Web.UI.Page
{
public static string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;
static OracleConnection Con = new OracleConnection(connectionString);
OracleCommand cmd = new OracleCommand("", Con);
DataSet ds = new DataSet();
dsSample ds10 = new dsSample();
protected void Page_Load(object sender, EventArgs e)
{
int id = 0;
getAllOrders(id);
if (Page.IsPostBack == true)
{
{
getSubOrders(id);
}
}
}
public DataTable getAllOrders(int id)
{
try
{
if (Con.State != ConnectionState.Open)
{
Con.Open();
}
ReportDocument rptDoc = new ReportDocument();
cmd.CommandText = "PKG_TEST_BIO.SP_GET_RECEIVED_DATA_PRATIP";
cmd.CommandType = CommandType.StoredProcedure;
OracleParameter Para_ID = new OracleParameter("temp_rnk", OracleDbType.Int32);
OracleParameter Para_RSCUR = new OracleParameter("nreturn", OracleDbType.RefCursor);
Para_ID.Direction = ParameterDirection.Input;
Para_ID.Value = id;
Para_RSCUR.Direction = ParameterDirection.Output;
cmd.Parameters.Add(Para_ID);
cmd.Parameters.Add(Para_RSCUR);
OracleDataAdapter adapter = new OracleDataAdapter(cmd);
adapter.Fill(ds, "DataTable1");
DataRow userDetailsRow;
foreach (DataRow row in ds.Tables[0].Rows)
{
userDetailsRow = ds10.Tables[0].NewRow();
userDetailsRow["RNK"] = Convert.ToInt32(row["RNK"].ToString());
userDetailsRow["TITLE"] = row["TITLE"].ToString();
userDetailsRow["RELEASED"] = Convert.ToInt32(row["RELEASED"].ToString());
userDetailsRow["GENRE"] = row["GENRE"].ToString();
ds10.Tables[0].Rows.Add(userDetailsRow);
}
ds.Tables[0].AcceptChanges();
rptDoc.Load(HttpContext.Current.Server.MapPath("~/Reports/CrystalReport3.rpt"));
rptDoc.SetDataSource(ds10.Tables[0]);
CrystalReportViewer3.ReportSource = rptDoc;
cmd.Dispose();
return ds.Tables[0];
}
catch (Exception ex)
{
Response.Write(ex.ToString());
return null;
}
}
Is there any need to create diff. instances of datasets or the .xsd file??
btw, i've created my tables "DataTable1" (Main) n "MORE_DETAILS" (for subreport) in the dsSample.xsd file all correct with proper links to fields.
what can be the possible reason for data not being populated in the datset for subreport when it's being populated in the mainreport??
Thanks in advance for your HELP!!!