关于sql server的水晶报表中的疑问 [英] doubt in crystal report regarding sql server

查看:84
本文介绍了关于sql server的水晶报表中的疑问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void Button1_Click(object sender, EventArgs e)
    {
        string sql;
        sql="SELECT customer1.username, customer1.FirstName, customer1.LastName, customer1.Address, customer1.city, customer1.state, customer1.contactno, productorder.orcode, productorder.ordate, productorder.icode, productorder.qty, productorder.rate, productorder.delidate
FROM customer1 LEFT JOIN productorder ON customer1.email = productorder.email
WHERE customer1.email="'" + Label1.Text + "'";
        adp = new SqlDataAdapter(sql,con);
        ds = new DataSet();
        adp.Fill(ds,sql);
        if (ds.Tables[sql].Rows.Count >= 0)
        {
            rd = new ReportDocument();
            rd.Load(Server.MapPath("CrystalReport7.rpt"));
            rd.SetDataSource(ds);
            CrystalReportViewer1.ReportSource = rd;
        }
    }


这是正确的吗?

因为我遇到了错误-语法不正确''..

请检查并告诉我.


is this correct?

Because I am getting the error - incorrect syntax near''.''.

Please check it and tell me.

推荐答案

如果您的代码段已粘贴到您的问题中,那么它给出了错误,我并不感到惊讶. sql字符串中的任何地方都没有空格.我试图对其进行编辑.请检查它是否正确.
If your code snippet was pasted into your question, then I am not surprised that it gave errors. There were no spaces anywhere in your sql string. I have attempted to edit it. Please check that it is correct.


顺便说一句,这行也是错误的:
rd.SetDataSource(ds);

应该是:
rd.SetDataSource(ds.Tables[0]);
BTW, this line is also wrong:
rd.SetDataSource(ds);

It should be:
rd.SetDataSource(ds.Tables[0]);


这篇关于关于sql server的水晶报表中的疑问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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