Click here to Skip to main content
15,746,652 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying Crystal report in my application where i have to display records with select * from tblcart where uname=xyz query. but i am geting following error . can anyone help me.

Thank you


String cn=System.Configuration.ConfigurationManager.ConnectionStrings["JBMConnectionString"].ToString();
SqlConnection con= new SqlConnection(cn);
SqlCommand command = new SqlCommand("Select * From tblcart where uname="+Session["uname"],con );
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataSet dataset = new DataSet();
ReportDocument CustomerReport = new ReportDocument();

CrystalReportViewer1.ReportSource = CustomerReport;


Server Error in '/JBM' Application.
Invalid column name 'b'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Invalid column name 'b'.

Source Error:

Line 19: //Customer _Customer = new Customer();
Line 20: DataSet dataset = new DataSet();
Line 21: adapter.Fill(dataset);
Line 22: ReportDocument CustomerReport = new ReportDocument();
Line 23: CustomerReport.Load(Server.MapPath("purchase.rpt"));
Updated 14-Jan-13 18:20pm

1 solution


Try This.

SqlCommand command = new SqlCommand("Select * From tblcart where uname='"+Session["uname"].ToString() +"' ",con );

Problem in your query may be missing single quote Or Session variable(object) conversion , Session variable(object) cannot convert automatic you have to convert it.

Mark it as Ans if it resolve your query...
Asp.Net/C#.Net Help[^]
Hemant Singh
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