on 09-02-2010 2:55 PM
How I can connect with Crystal Reports 2008 SP 3 to WCF Data Service (OData) for gathering data?
Hi Sulmar,
Licky you, I just worked with this...
I assume that you are working in .NET / Visual Studio - right? First you have to create a DataSet in your project, defining your data model. Based on this DataSet you can build your CR with the DataSet as data source.
After this you have to map your incoming data from OData service to your DataSet. this can be done simiar to the following example where I map data from the SFlight data model to the DataSet which is the base for my CR:
static private void generateCRFlight(DataTable inDataTable)
{
//Create data set to be consumed by crystal report
DataSetFlight dataSetFlight = new DataSetFlight();
DataTable theDataTable = dataSetFlight.Tables.Add(("FlightData"));
theDataTable.Columns.Add("CarrID", Type.GetType("System.String"));
theDataTable.Columns.Add("ConnID", Type.GetType("System.String"));
theDataTable.Columns.Add("FlDate", Type.GetType("System.DateTime"));
theDataTable.Columns.Add("Price", Type.GetType("System.Decimal"));
theDataTable.Columns.Add("Currency", Type.GetType("System.String"));
theDataTable.Columns.Add("PlaneType", Type.GetType("System.String"));
theDataTable.Columns.Add("SeatsMax", Type.GetType("System.Int32"));
theDataTable.Columns.Add("SeatsOcc", Type.GetType("System.Int32"));
int rowCounter = 0;
int numberOfRows = inDataTable.Rows.Count;
for (rowCounter = 0; rowCounter < numberOfRows; rowCounter++)
{
DataRow theDataRow = theDataTable.NewRow();
theDataRow[0] = inDataTable.Rows[rowCounter][0];
theDataRow[1] = inDataTable.Rows[rowCounter][1];
theDataRow[2] = inDataTable.Rows[rowCounter][2];
theDataRow[3] = inDataTable.Rows[rowCounter][3];
theDataRow[4] = inDataTable.Rows[rowCounter][4];
theDataRow[5] = inDataTable.Rows[rowCounter][5];
theDataRow[6] = inDataTable.Rows[rowCounter][6];
theDataTable.Rows.Add(theDataRow);
}
CRFlight theCrystalReport = new CRFlight();
theCrystalReport.SetDataSource(dataSetFlight.Tables[1]);
ReportViewer theReportViewer = new ReportViewer(theCrystalReport);
theReportViewer.Show();
}
see as well the follwoing article: [Creating Crystal Reports using C# with Datasets|http://www.codeproject.com/KB/cs/CreatingCrystalReports.aspx]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The Open Data Protocol (OData) is a Web protocol for querying data. (http://www.odata.org/)
WCF Data Services is implementation of OData protocol by Microsoft.
Crystal Reports 2008 SP 3 has just support WCF Services. I think that is good idea to add support OData to Crystal Reports.
IMO this forum is good place for this subject.
Hello,
We don't specifically have a driver for it. As a work around create a report off the ADO.NET driver to use a record set and then move the WCF data into the DS. Then CR can use it.
Add your request to the Idea Place, if it gets enough votes Product will look into adding it as a supported data source.
I'll get one of the PM for Cr to look at this post and comment on the functionality...
Thank you
Don
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.