在Form2里面添加button7控件,并添加以下程序;
在Form3里面添加CrystalReportView控件,选择水晶报表CrystalReport1.rpt;
运行后点button7能够连接数据库,出现报表,但是报表只显示标题一行,不能显示具体内容(如红色描述的)!问题:是程序有错吗?
      怎么能使报表显示详细内容?
private void button7_Click(object sender, EventArgs e)
        {
            this.Hide();
            Form3 f = new Form3();
            f.ShowDialog();            string dbConnString = "Data Source=DEEPBBS-1151;Initial Catalog=lo;uid = sa; pwd = 2013shujukumima;";
            string sql = string.Format("update [test] set 试验标准='10s内漏泄量≤2Kpa',试验结果='漏泄量{0}Kpa',试验结论='{1}' where 试验项目='集尘器气密性试验' ", numericUpDown1.Text, textBox6.Text);
            try
            {                SqlConnection conn = new SqlConnection(dbConnString);
                {
                    SqlCommand cmd = new SqlCommand(sql, conn);
                    conn.Open();
                    int val = cmd.ExecuteNonQuery();
                    conn.Close();                }
            }            catch (Exception exp)
            {                MessageBox.Show(exp.Message);
            }
            
        }vs2008报表

解决方案 »

  1.   

    private void button7_Click(object sender, EventArgs e)
            {
                this.Hide();
                Form3 f = new Form3();
                f.ShowDialog();            string dbConnString = "Data Source=DEEPBBS-1151;Initial Catalog=lo;uid = sa; pwd = 2013shujukumima;";
                string sql = string.Format("update [test] set 试验标准='10s内漏泄量≤2Kpa',试验结果='漏泄量{0}Kpa',试验结论='{1}' where 试验项目='集尘器气密性试验' ", numericUpDown1.Text, textBox6.Text);
                try
                {                SqlConnection conn = new SqlConnection(dbConnString);
                    {
                        SqlCommand cmd = new SqlCommand(sql, conn);
                        conn.Open();
                        int val = cmd.ExecuteNonQuery();
                        conn.Close();                }
                }            catch (Exception exp)
                {                MessageBox.Show(exp.Message);
                }
                
            }
      

  2.   


    第一个是Form2的图,第二个是报表CrystalReport1的图,要在报表中显示第一个图最后一行的漏泄量numericUpDown1内的数值,和结果textBox6的内容(合格或不合格)。
    漏泄量numericUpDown1的值是Form2运行时随意输入的,同时影响textBox6的内容。(例如,漏泄量输入0.1KPa/s,则结果为合格;漏泄量为0.4,则不合格)所以用语句 string sql = string.Format("update [test] set 试验标准='10s内漏泄量≤2Kpa',试验结果='漏泄量{0}Kpa',试验结论='{1}' where 试验项目='集尘器气密性试验' ", numericUpDown1.Text, textBox6.Text);
    希望能在报表输出漏泄量和结果。
    要怎么改?
      

  3.   


    用的是数据库lo的表test
    因为漏泄量numericUpDown1不是固定的一个数,所以没有直接在表test里面填上,通过sql语句赋值可以做到吗?