Click here to Skip to main content
13,046,176 members (84,262 online)
Rate this:
Please Sign up or sign in to vote.
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"));
Posted 14-Jan-13 18:17pm
Updated 14-Jan-13 18:20pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1


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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 15 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100