title: "System.Data.SqlClient.SqlException: 'Incorrect syntax near ')'.'" error
body: <p>I am new to asp.net programming</p>
  
  <p>I keep getting this error:</p>
  
  <blockquote>
    <p>System.Data.SqlClient.SqlException: 'Incorrect syntax near ')'</p>
  </blockquote>
  
  <p>near </p>
  
  <pre><code>sqlcomm.ExecuteNonQuery();
  </code></pre>
  
  <p>This is my complete code:</p>
  
  <pre><code>[HttpPost]
  public ActionResult Index(UserClass uc,HttpPostedFileBase file)
  {
      string mainconn = ConfigurationManager.ConnectionStrings["Myconnection"].ConnectionString;
  
      SqlConnection sqlconn = new SqlConnection(mainconn);
  
      string sqlquery = "insert into [dbo].[MVCregUser] (Uname, Uemail, Upwd, Gender, Uimage) values (@Uname, @Uemail, @Upwd, @Gender, @Uimage,)";
      SqlCommand sqlcomm = new SqlCommand(sqlquery, sqlconn);
  
      sqlconn.Open();
  
      sqlcomm.Parameters.AddWithValue("@Uname",uc.Uname);
      sqlcomm.Parameters.AddWithValue("@Uemail", uc.Uemail);
      sqlcomm.Parameters.AddWithValue("@Upwd", uc.Upwd);
      sqlcomm.Parameters.AddWithValue("@Gender", uc.Gender);
  
      if(file != null &amp;&amp; file.ContentLength &gt; 0)
      {
          string filename = Path.GetFileName(file.FileName);
          string imgpath = Path.Combine(Server.MapPath("~//User-Images"), filename);
          file.SaveAs(imgpath);
      }
  
      sqlcomm.Parameters.AddWithValue("@Uimage", "~//User-Images"+file.FileName);
  
      sqlcomm.ExecuteNonQuery();
      sqlconn.Close();
  
      ViewData["Message"] = "User Record " + uc.Uname + " Is Saved Successfully";
      return View();
  }
  </code></pre>