Syntax error in INSERT INTO statement



  • It's been half a day over the mistake. I tried everything. Here's the code: Mistake: "Syntax error in INSERT INTO statement."

            using (OleDbConnection conn = new OleDbConnection(Form1.ConnectionString))
            {
                conn.Open();
    
            OleDbCommand cmd = new OleDbCommand();
            cmd.CommandType = CommandType.Text;
    
    
    
            cmd.CommandText = "insert into Session" +
                " ([total_price]) values (@total_price );";
    
    
       cmd.Parameters.AddRange(new OleDbParameter[]
      {
    
           new OleDbParameter("@total_price", Convert.ToUInt64(textBox1.Text))
       });
    
    
            cmd.Connection = conn;
    
            cmd.ExecuteNonQuery();
    
            conn.Close();
    
        }
    

    And it doesn't work just to walk this table because there's no mistake in others, although it doesn't. ♪ ♪
    Because the table violin:
    введите сюда описание изображения

    Where the client_id and worker_id - through the master of the substation is linked to other tables (hz, may influence).

    Thank you!



  • Try adding the parameter by:

    cmd.Parameters.AddWithValue("@total_price", Convert.ToUInt64(textBox1.Text));
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2