Click here to Skip to main content
15,901,368 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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.
Posted
Updated 10-Feb-11 1:42am
v2
Comments
Sandeep Mewara 10-Feb-11 7:54am    
Also, when you debug it, which line says error? Looks like SQL only, but do confirm.

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.
 
Share this answer
 
BTW, this line is also wrong:
rd.SetDataSource(ds);

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900