Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 不使用xsd文件创建crystal报告_C#_Wcf_Crystal Reports - Fatal编程技术网

C# 不使用xsd文件创建crystal报告

C# 不使用xsd文件创建crystal报告,c#,wcf,crystal-reports,C#,Wcf,Crystal Reports,我需要一些帮助来解决这个问题 基本上,我有一个Wcf服务,它使用crystal report生成报告。Crystal report使用XSD作为数据源 我想删除XSD,并使用连接到数据库并提供结果的数据服务(WCF) 简言之,试图将报表逻辑与数据逻辑分开,但如果有任何示例展示这种方法,则不确定如何开始 WCF数据服务是微软对OData协议的实现。要对Crystal Reports使用OData协议,可以使用以下步骤: 首先,必须在项目中创建一个数据集,定义数据模型。基于此数据集,您可以使用该数据

我需要一些帮助来解决这个问题

基本上,我有一个
Wcf
服务,它使用crystal report生成报告。Crystal report使用XSD作为数据源

我想删除
XSD
,并使用连接到数据库并提供结果的数据服务(
WCF


简言之,试图将报表逻辑与数据逻辑分开,但如果有任何示例展示这种方法,则不确定如何开始

WCF数据服务是微软对OData协议的实现。要对Crystal Reports使用OData协议,可以使用以下步骤: 首先,必须在项目中创建一个数据集,定义数据模型。基于此数据集,您可以使用该数据集作为数据源来构建CR。 在此之后,您必须将来自OData服务的传入数据映射到数据集。这可以类似于以下示例,其中我将数据从SFlight数据模型映射到作为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();
    }
static private void generatecrfright(DataTable inDataTable)
{
//创建crystal report要使用的数据集
DataSetFlight DataSetFlight=新的DataSetFlight();
DataTable theDataTable=dataSetFlight.Tables.Add((“FlightData”);
data.Columns.Add(“CarrID”,Type.GetType(“System.String”);
data.Columns.Add(“ConnID”,Type.GetType(“System.String”);
data.Columns.Add(“FlDate”,Type.GetType(“System.DateTime”);
data.Columns.Add(“Price”,Type.GetType(“System.Decimal”);
data.Columns.Add(“Currency”,Type.GetType(“System.String”);
data.Columns.Add(“PlaneType”,Type.GetType(“System.String”);
data.Columns.Add(“SeatsMax”,Type.GetType(“System.Int32”);
datatable.Columns.Add(“SeatsOcc”,Type.GetType(“System.Int32”);
int rowCounter=0;
int numberOfRows=inDataTable.Rows.Count;
对于(rowCounter=0;rowCounter
另见以下文章: