Last post Aug 27, 2012 01:01 AM by Ajay2707
Aug 26, 2012 09:32 AM|jckaito04|LINK
Hi! Im having problems in creating a crystal reports using a dataset having multiple tables. What i want is that, my crystal report can generate report using the 2 datatable inside my dataset. whenever i use only one table from the dataset, it works but
when i use more than 1 table, nothing appears in my crystal report. My rpt file is referenced to the dataset i added to my project .here is my code below, i do hope that you help me with this. Thank you.
int ProjectID, OwnerID;
ProjectIDHiddenField.Value = "1000001";
OwnerIDHiddenField.Value = "1000001";
OwnerID = int.Parse(OwnerIDHiddenField.Value);
ProjectID = int.Parse(ProjectIDHiddenField.Value);
da1.SelectCommand = new SqlCommand("SELECT FirstName, MiddleName, LastName, Address, ContactNo, EmailAddress, Username, Password FROM ProjectOwnersTable WHERE OwnerID='" + OwnerID + "'", cs);
da2.SelectCommand = new SqlCommand("SELECT ProjectName, ProjectLocation, ScopeOfWork, DateOfContract, Duration, ProjectStatusInPercent, ContractAmount, DiscountAmount, DPAmount, TotalAmtPaid, TotalBalance, TotalRetention FROM ProjectInformationTable WHERE ProjectID='" + ProjectID + "' AND OwnerID='" + OwnerID + "'", cs);
ProjInfoCrystalReportViewer.ReportSource = report;
Just don't mind about the OwnerID and ProjectID because the report that i am trying to make is a defined report wherein only record pertaining to those 2 ids will be shown.
Aug 26, 2012 12:10 PM|chandana|LINK
You don't need to merge the table; insted you can create the report using both table. if the rows is different one side of table show null values.
if you want to get rows for one id or something from both table the easy way is first create datatable(static) in dataset with required column to create report and create same type data table using given two tables at runtime and assign it to static table.
Aug 27, 2012 01:01 AM|Ajay2707|LINK
Why you fill the data in cs? This is not good approach.
For this make one sp with select statement with 2 parameter (1.
) , in query select all column which you need in report and inner join the 2 table.(as your select statement show).
Then in report, place the column, on other side the above code will change and use to sent 2 parameter for report.