Click here to Skip to main content
15,894,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

Thanks in advance, I'm having some issues in generating sub report from 2 table. i have ask this question in earlier as well, but i didnt get proper answer. Please any one can explain clearly how to accomplish this task. thanks in advance again.

These are my 2 tables,-Cost, Item
COST ITEM
------------------------------- ---------------------------------------
Product_ID Name Weight Piece Product_ID Item Unite_Price Qty type
---------- ----- ------ ----- ---------- ----- ------------ --- ----
001 Chocolate 15g 120 001 choco $12 1.2 R
002 Bread 20g 80 001 milk $15 1.8 R
001 flour $10 2.5 P
002 flour $10 3.5 P
002 east $20 0.8 R
002 bag $10 2.0 R
with these table I need a report like below,
/////////////////////////////////////////////////////////////////////////////////
Product ID-001 Name - Chocolate Weight - 15g Piece - 120
----------------------------------------------------------

Product_ID Item Unite_Price Qty type
---------- ---- ----------- --- ----
001 choco $12 1.2 R -:here with like command I have take
001 milk $15 1.8 R Only "Type like 'R%' "

Product_ID Item Unite_Price Qty type
---------- ---- ----------- --- ----
001 flour $10 2.5 P -:here with like command I have take
Only "Type like 'P%' "
/////////////////////////////////////////////////////////////////////////////////

how can I accomplish this task please any one can help me in this task.
What i did is , I have taken all these as separate dataset with sub reports and try to insert into main report. but subreports are working and generating the values main report is not only generating the headings... please can any one tell me how to do this..
Posted
Comments
Prasad_Kulkarni 5-Mar-12 7:39am    
its Crystal not Vrystal you might spelled wrongly,

1 solution

 
Share this answer
 
Comments
ruzan hizar 6-Mar-12 2:20am    
Thanks for the help...but it also not supporting in my case. I'm taking the data from Access database using XML dataset and assigning the dataset to an object. from that object only i'm taking to the report.
here is my code...

DataTable dt = new DataTable();
Class.clsReport rpt = new Cost.Class.clsReport();
dt = rpt.GenerateMainReport(Pcode);

DataSet ds = new dsReport();
foreach (DataRow dr in dt.Rows)
{
ds.Tables["mainReport"].ImportRow(dr);
}
Report.MainReport objMain = new MainReport();
objMain.SetDataSource(ds);

crvMain.ReportSource = objMain;
crvMain.Refresh();
--------------------------------------------------------------------
public DataTable GenerateMainReport(string Pcode)
{
DataTable ds = new DataTable();
try
{
string sqlStr = "SELECT * FROM tblCost WHERE Product_Code = '" + Pcode + "'";

con = new OleDbConnection(clsConnection.connect);
con.Open();

da = new OleDbDataAdapter();
da.SelectCommand = new OleDbCommand(sqlStr, con);
da.SelectCommand.ExecuteNonQuery();
da.Fill(ds);
return ds;
}
catch (Exception ee)
{
throw ee;
return ds;
}
}
Please any one can check this codes and let me know if any other easy ways to do this task... because i'm new to c#...
Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900