title: Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax near 'Programming'
body: <p>I'm using a button to add product to database when clicking it. this is the code which I written, but it creates an unhandled exception. please help me to correct it...</p>
  
  <pre><code>protected void Button1_Click(object sender, EventArgs e)
  {
      string s = @"~\Images" + FileUpload1.FileName;
      FileUpload1.PostedFile.SaveAs(Server.MapPath(s));
      string ConStr = ConfigurationManager.ConnectionStrings["HoriZon"].ConnectionString;
      SqlConnection NewCon = new SqlConnection(ConStr);
      NewCon.Open();
  
      String cmd1 = "INSERT INTO Subjects(SubjectName, Description, ImagePath, UnitPrice, CategoryID) values('" + name.Text + "','" + description.Text + "','" + s + "', '" + price.Text + "', '" + "SELECT CategoryID FROM dbo.Categories WHERE CategoryName = '" + catText.Text + "'" +"')";
      SqlCommand b = new SqlCommand(cmd1, NewCon);
  
      b.ExecuteNonQuery();
  
      NewCon.Close();
  }
  </code></pre>