设置.xsd数据集值 [英] Set .xsd DataSet Values

查看:39
本文介绍了设置.xsd数据集值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储过程,该过程使用数据表返回值.返回的数据如下:

I got a stored procedure that returns values using a datatable. The returned data looks like:

Column1    Column2    Column3
 
1          2          John Smith


问题:我需要将这些值分配给我的.xsd行


The problem: I need to assign these values to my .xsd row

NUMBER1   NUMBER2   CUSTOMER


dt是我的数据表,ds是我的.xsd数据集.

我的代码:


dt is my datatable, ds is my .xsd dataset.

My Code:

ReportDocument rptCheck = new ReportDocument(); 
            dsCheck ds = new dsCheck(); // .xsd file name 
            DataTable dt = new DataTable(); 
 
             dt = getChecks(); // Sets datatable  
            // Your .rpt file path will be below 
            rptCheck.Load(Server.MapPath("checkprt.rpt"));        
 
            //set dataset to the report viewer. 
            rptCheck.SetDataSource(ds);                  
            CrystalReportViewer1.ReportSource = rptCheck;

推荐答案

我可以知道为什么要将数据表存储到数据集吗?
根据您的代码,您希望数据表在crystalreport中显示记录.在这里,我将向您展示一些示例:

从报告表格中调用此
may i know why do you wanna store datatable to dataset?
As per your code you want datatable to display records in crystalreport. Here i''ll show you some example:

Call this from report form
string sqlQuery ="select * from your table";//put your search condition
adp = new SqlDataAdapter(sqlQuery, connection);
dt = new DataTable();
adp.Fill(dt);
CRViewer cvph = new CRViewer();
cvph.dt = dt;
cvph.Show();



CRViewer形式:
它包含一个名为crystalReportViewer1的crystalReportViewer



CRViewer form:
It contains a crystalReportViewer named crystalReportViewer1

public partial class CRViewer : Form
    {
        public CRViewer()
        {
            InitializeComponent();
        }
        public DataTable dt = new DataTable();
        private void CRViewer_Load(object sender, EventArgs e)
        {
            CRCustomer crph = new CRCustomer();//CRCustomer is the crystal Report
            crph.Database.Tables[0].SetDataSource(dt);
            crystalReportViewer1.ReportSource = crph;
        }
    }


我最终以这种方式完成了工作.但是我想通过调用存储过程并对.xsd文件使用数据表来了解为什么它不起作用. Thx
I ended up doing it that way and it works. But I''d like to know why it doesn''t work by calling the store procedure and using the datatable for the .xsd file. Thx


这篇关于设置.xsd数据集值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆