I have a datagridview with a number of selected rows. What I need to do is be able to create a crystal report that shows the selected rows. Does anyone know where to start with this cause I'm at a loss, the only solution I could come up with is to create a table in a database and add each row and then create a report from the table, this is not idel.
So if anyone knows where to start please do let me know.
First step is if you know what the schema (columns and data type of the data that will be used) then create a xsd file and create the report off of that. At runtime you can pass a dataset object to the report. You can modify your dataset that is used to pass the data to the datagridview to only contain the rows that are selected.
ReportDocument myReport = new ReportDocument(); myReport.Load(@"C:\myreport.rpt");
//create the modified dataset with the rows selected
Proposed as answer byneonprimetimeFriday, August 29, 2008 8:46 PM
I have a report that pulls data based on what is selected in a combo box. And believe me, I needed major help with this one and it is still pretty confusing but maybe it will at least give you a starting point. Here is my stored procedure (the '''' around the end date, are 4 single quotes not two double quotes)
CREATE PROCEDURE [usp_rptSingleUnitReport] @EndingDate VarChar(100), @Where varchar(1000) -- AS SET NOCOUNT ON declare @SQL varchar(8000) set @sql=' SELECT p.ProjectID, p.ProjectDescription, p.FileNumber, u.UnitDescription, u.Building, u.UnitDescriptionForSort, u.Buyer, ft.TransactionTypeID, ft.TransactionDate, CASE WHEN ft.TransactionTypeId = 1 THEN ft.Amount ELSE 0 END AS CashDeposits, CASE WHEN ft.TransactionTypeID = 2 THEN ft.amount ELSE 0 END AS CashDisburse, ' + '''' + @EndingDate + '''' + ' as EndingDate FROM dbo.Project p INNER JOIN dbo.Unit u ON p.ProjectID = u.ProjectID INNER JOIN dbo.FinancialTransaction ft ON fa.FinancialAccountID = ft.FinancialAccountID
WHERE ft.UnitID in (' + @Where + ') AND ft.TransactionDate<= ' + '''' + @EndingDate + ''''
exec (@SQL) GO
And this is to pass the paramater
if (objReports.CurrentReportId==28) //Single Unit Report
System.Data.SqlClient.SqlParameter par =
int size = 0;
new System.Data.SqlClient.SqlParameter("EndingDate", SqlDbType.DateTime);
string selectedRows ="";
foreach(UltraGridRow dr in dgUnits.Rows)