【问题标题】:Select id record view by Report viewer通过报告查看器选择 id 记录视图
【发布时间】:2020-02-02 02:09:05
【问题描述】:

当我在 form1.form2 的文本框中输入 id 时,报告查看器显示了记录。但它不会显示所有数据,显示表中的内容。

我已经创建了 dataset1 并加载了值。

Form1

Form2 frm2 = new Form2();
frm2.studentid = textBox1.Text;
frm2.Show();   

Form2

string id = studentid;

this.recordsTableAdapter.FillBy(this.DataSet1.records, id);
//  by **this line Gereate sub for by** i am a beginner of Report viewer         

this.recordsTableAdapter.Fill(this.DataSet1.records);

this.reportViewer1.RefreshReport();

private string id;

public string studentid
{
    get { return id; }
    set { id = value; }
}

我编写查询的数据集

SELECT id, firstname, lastname FROM dbo.records where id = ?

【问题讨论】:

  • 你遇到了什么错误?
  • this.recordsTableAdapter.FillBy(this.DataSet1.records, id);通过这一行 Gereate sub for by
  • 你能不能再描述一下问题,我无法理解“this line Gereate sub for by”
  • WindowsFormsApplication27.exe 中出现“System.NotImplementedException”类型的未处理异常附加信息:方法或操作未实现。
  • i Gereate sub for by fillBy 然后我在文本框上输入 id 单击查找按钮显示错误 n 在 WindowsFormsApplication27.exe 中发生“System.NotImplementedException”类型的未处理异常

标签: c# winforms reportviewer


【解决方案1】:

您正在使用throw new System.NotImplementedException(); 在您的方法上抛出此异常。您需要删除此行并在此处添加一些逻辑。

public partial class recordsTableAdapter {
    internal void FillBy(DataSet1.recordsDataTable recordsDataTable, string id)
    {
        // Remove exception and do something with your datatable.
    }
}

See doc for NotImplementedException

当特定方法、get 访问器或 set 访问器作为类型的成员存在但未实现时,将引发 NotImplementedException 异常。

NotImplementedException 使用默认的 Object.Equals 实现,它支持引用相等。有关 NotImplementedException 实例的初始值列表,请参阅 NotImplementedException 构造函数。

您可以选择在您自己的类型中的属性或方法中抛出 NotImplementedException 异常,当该成员仍处于开发阶段并且稍后才会在生产代码中实现时。换句话说,NotImplementedException 异常应该是“仍在开发中”的同义词。

【讨论】:

  • 如果我删除了该行错误消失但结果不是显示 id 我输入的内容,它会将所有数据显示给reportviewer
  • 现在您需要实现过滤数据集的代码
  • 您需要就您的问题分享更多信息。 this.DataSet1 的类型是什么?
  • 我用屏幕截图更新了上面的DataSet1,请检查并给我解决方案
  • 请看这个问题。它可以帮助您过滤数据表stackoverflow.com/questions/3178316/…
猜你喜欢
  • 1970-01-01
  • 2017-03-08
  • 1970-01-01
  • 2012-06-16
  • 1970-01-01
  • 2021-04-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多