gpt4 book ai didi

c# - 带有 SQL 查询的 Crystal Reports

转载 作者:太空宇宙 更新时间:2023-11-03 11:04:04 25 4
gpt4 key购买 nike

我正在使用 Crystal Report,但现在遇到了问题。我正在使用 visual studio 2010。

    private void button1_Click(object sender, EventArgs e)
{
SqlCommand com = new SqlCommand("Select * from Students where StudentID='" + textBox1.Text + "'", conn);
adap.SelectCommand = com;
adap.Fill(tables);
CrystalReport1 myreport = new CrystalReport1();
myreport.SetDataSource(tables);
crystalReportViewer1.ReportSource = myreport;
}

我写了这段代码,但它不起作用。我的意思是 Crystal Report 向我显示了数据库中的所有学生。我只想要文本框中带有 StudentID 的特定学生。但它曾经在另一个项目上工作过。我打开新项目,一切都一样,但现在不起作用。

请帮帮我。

最佳答案

   private void button1_Click(object sender, EventArgs e)
{
SqlCommand com = new SqlCommand("Select * from Students where StudentID='" + textBox1.Text + "'", conn);
adap.SelectCommand = com;
adap.Fill(tables);
ReportDocument doc;
CrystalReport1 myreport = new CrystalReport1();
myreport.SetDataSource(tables);
doc = new ReportDocument();
doc.Load(Server.MapPath("RptName.rpt"));
myreport.ReportSource = doc;
myreport.ReportSource = myreport;
}

关于c# - 带有 SQL 查询的 Crystal Reports,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16618046/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com