Carol Cashman

Carol Cashman

  • NA
  • 74
  • 10.7k

how to fix Server Error in '/' Application Error??

Jan 9 2018 11:40 AM
Hi guys,
 
i am trying to populate my database with detals i enter in my webform to save into the database but i receive this error :
 
Server Error in '/' Application.
Incorrect syntax near the keyword 'Order'.
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.
 
This is my code:
 
protected void Button1_Click1(object sender, EventArgs e)
{
//Creating a connection to my database using the connection string
string cs = System.Configuration.ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(cs);
//preparing a query which will insert the data entered in the textboxes to the database
SqlCommand cmd = new SqlCommand("INSERT INTO Order(OrderDate, CustomerID, LidNo, StickerNo, LJarNo, SJarNo) values('" + this.txtDate.Text + "' ,'" + this.txtId.Text + "','" + this.txtLids.Text + "','" + this.txtStickers.Text + "','" + this.txtLargeJars.Text + "','" + this.txtSmallJars.Text + "')", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
Response.Redirect("Orders.aspx");
}
 
and my database looks like this:
 
 
 
any help is greatly appriciated!

Answers (12)