on 09-02-2008 7:45 AM
Hi to all,
I'm using CR 11.5, Visual Studio 2005-C#,asp.net and SQL server 2005.
My work is during runtime to add the Fieldobjects in
crystal report now i can do it but during design time i added
the Table in Crystal Report ->FieldObjects>Database Fields
by that programaticaly i can add the Fieldobjects.
What i try to do is
to add the table to CR Database fields by programaticaly.
Is this possible then experts please help me.
Thanks in advance
this is a good code
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found a way like this
private void AddTableFromDataSet(ref CrystalDecisions.CrystalReports.Engine.ReportDocument rpt, System.Data.DataSet ds)
{
ISCDReportClientDocument rasReport = rpt.ReportClientDocument;
// Convert the DataSet to an ISCRDataset object (something the ISCDReportClientDocument can understand)
CrystalDecisions.ReportAppServer.DataDefModel.ISCRDataSet rasDS;
rasDS = CrystalDecisions.ReportAppServer.DataSetConversion.DataSetConverter.Convert(ds);
// Add the dataset as a data source to the report
rasReport.DatabaseController.AddDataSource((object)rasDS);
// Add a field to the report canvas
// Note: This is quick and dirty. No positioning, resizing, formatting, etc.
CrystalDecisions.ReportAppServer.Controllers.ISCRResultFieldController rfc;
CrystalDecisions.ReportAppServer.DataDefModel.ISCRTable crTable;
CrystalDecisions.ReportAppServer.DataDefModel.ISCRField crField;
rfc = rasReport.DataDefController.ResultFieldController;
crTable = rasReport.Database.Tables[0];
crField = crTable.DataFields[2]; // Hardcoded field "Customer Name" in the Customer table from Xtreme Sample Database
rfc.Add(-1, crField);
// Save the report template to disk (without data)
//object path = @"c:\documents and settings\administrator\desktop\";
//rasReport.SaveAs("test.rpt", ref path, 0);
//MessageBox.Show("Done!");
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 3 | |
| 3 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.