title: incorrect syntax near ');
body: <p>I have an error with my code.</p>
  
  <p>Code execution directly flows to the catch block and says: <code>incorrect syntax near ');</code> </p>
  
  <p>I want to save a file in the database and call it again.</p>
  
  <pre><code>public partial class newsrv : System.Web.UI.Page{
      string dir = "C://fileup//";
  
      protected void Page_Load(object sender, EventArgs e){
          if (!Directory.Exists(dir)){
              Directory.CreateDirectory(dir);
          }
      }
  
      protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e){
  
      }
  
      protected void Button1_Click(object sender, EventArgs e){
          SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|DB.mdf;Integrated Security=True;User Instance=True");
          string fname = FileUpload1.PostedFile.FileName;
          try{
              SqlCommand cmd = new SqlCommand("INSERT INTO OrderNum (SrviceType, Msg,[File]) VALUES ('" + DropDownList1.SelectedItem.Text + "','" + TextBox1.Text + "' ,'" + FileUpload1.PostedFile.FileName + "') );", con);
              con.Open();
  
              try {
                  int res = cmd.ExecuteNonQuery();
                  if (res &gt; 0){
                      System.Windows.Forms.MessageBox.Show("success");
                  }
                  Label2.Text = TextBox1.Text;
                  FileUpload1.SaveAs(dir + fname);
                  Label1.Text = " file name uploaded succ ";
                  FileUpload1.Visible = true;
              }catch (Exception ex){
                  System.Windows.Forms.MessageBox.Show(ex.Message);
              }
          }catch{
              Label1.Text = " file name  not uploaded  ";
              FileUpload1.Visible = false;
              con.Close();
          }finally{
              con.Close();
          }
      }
  
      protected void TextBox1_TextChanged(object sender, EventArgs e){
  
      }
  }
  </code></pre>