Hi There,

This is my code. I'm pretty sure that theres nothing wrong so far with this code. But gives me an unexpected error. The error says, Invalid column name 'Sep'. But, even through out the whole code, nor on the database theres any column or word called, 'Sep'. So what does this error mean and whats the quickest solution? Appreciate anyone who can help me with this.

conn.Open();


SqlCommand sql1 = new SqlCommand();
sql1.Connection = conn;
sql1.CommandType = CommandType.Text;
sql1.CommandText = "Select SalesOrder.OrderNo, SalesOrder.CustCode, Customer.CustName, SalesOrder.OrderDate, SalesOrder.ExpDelDate, SalesOrder.ActDelDate, SalesOrder.OrderAmt, (SalesOrder.OrderAmt-SalesOrder.OrderCost)/SalesOrder.OrderAmt*100 AS GM, SalesOrder.RepCode, SalesOrder.StatusCode, SalesOrder.UserName, Rep.RepName, SalesOrder.StatusDesc From SalesOrder, Customer, Rep Where SalesOrder.OrderDate = " + lblDate.Text + " ";
DataSet ds1 = new DataSet();
SqlDataAdapter da1 = new SqlDataAdapter(sql1);
da1.Fill(ds1,"report");

lblDate.Visible = true;
GridView1.Visible = true;

GridView1.DataSource = ds1;
GridView1.DataMember = "report";

conn.Close();


Thanx.
Cheers.

AZ.

OrderDate = " + lblDate.Text + " "; is where the problem is. The lblDate.Text is probably something like "Sep 21, 2008". You need to quote the date (at least) or learn to use parameters (best).

Quoting the date is simple, just change that part to OrderDate = [B]'[/B]" + lblDate.Text + "[B]'[/B] "; Parameters

Thank u very much mate.. My problem is sloved.
Cheers

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.