title: Get "jdbc.SQLServerException: Incorrect syntax near ','" error when exececute PreparedStatement
body: <p>I wrote some java code to insert data into SQL Server 2012's Database when the user presses a button. When I run the code, I get this error:</p>
  
  <blockquote>
    <p>com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near ','.</p>
  </blockquote>
  
  <p>and it says that the <code>sqlstatement.executeUpdate();</code> line caused the error. I know that this line is not a problem. The problem is my sql query but I cannot find how my query is wrong. Would you please help me?</p>
  
  <p>Here the code </p>
  
  <pre><code>count++;
  for(int count = 0; count &lt; table_1.getRowCount(); count++){
      try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
            Connection dbconbt8 = DriverManager.getConnection("" +"jdbc:sqlserver://localhost;databaseName=Store;user=sa;password=XXXXXX");
            String sqlQ = "INSERT INTO [dbo].[Transaction]([TransactionID],[ProductID]"+
             ",[TotalPrice]) VALUES ("+count+"','"+table_1.getValueAt(count, 0).toString()+"','"+sumprice+ "') ";
             PreparedStatement sqlstatement = dbconbt8.prepareStatement(sqlQ);
             sqlstatement.executeUpdate();
                         sqlstatement.close();
                         dbconbt8.close();
              } catch (SQLException e1) {
  
                            e1.printStackTrace();
                        } catch (ClassNotFoundException e1) {
                          // TODO Auto-generated catch block
                          e1.printStackTrace();
                      }
                    }
  </code></pre>