首页 > 解决方案 > 我正在尝试使用 Visual Studio 2017 中的 Crystalreport 从数据库集中打印标签

问题描述

我正在尝试在 Visual Studio 2017 中创建一个标签应用程序,该应用程序使用数据库集来存储数据并同时以标签的形式打印这些数据。

但是,我无法将数据从数据库获取到标签。例如,当我点击“打印”按钮时,它会提示您输入您的采购订单号,然后点击确定;然后它会显示一个窗口,其中包含所有字段的名称但没有数据。

这是我的“打印”按钮的C#:

 private void print_Click(object sender, EventArgs e)
    {
        DataSet ds = new DataSet();
        DataTable dtd = new DataTable();

        dtd.Columns.Add("Your P.O #", typeof(string));
        dtd.Columns.Add("Your Job #", typeof(string));
        dtd.Columns.Add("Title", typeof(string));
        dtd.Columns.Add("Quantity in the Box", typeof(string));
        dtd.Columns.Add("Box", typeof(string));
        dtd.Columns.Add("of", typeof(string));

        foreach (DataGridViewRow dtgv in dtgv.Rows)
        {
            dtd.Rows.Add(dtgv.Cells[1].Value, dtgv.Cells[2].Value, dtgv.Cells[3].Value, dtgv.Cells[4].Value, dtgv.Cells[5].Value, dtgv.Cells[6].Value);
            

        }

            ds.Tables.Add(dtd);
            ds.WriteXmlSchema("sticker.mdf");

        prtsticker fm = new prtsticker();
        stickerprint cr = new stickerprint();

        cr.SetDataSource(ds);
        fm.Show();





    }

标签: c#databaseprintingvisual-studio-2017crystal-reports

解决方案


推荐阅读