Why is this not working? I can not even change the primary keys, why do I have a primary key when I add the price field?

enter image description here

string sql = "INSERT INTO items (Name, Href, Price) VALUES (@title, @href, @price1) ON DUPLICATE KEY UPDATE `Price`=VALUES(`Price`);"; 

upd enter image description here

  • one
    What does it mean to "put a primary key" and what does it mean to add a price field, it already has it in the table - Mike
  • @Mike when I added the Price field to the table, the field was created, and unlike the others, it has the Primary key highlighted. I thought maybe this is the problem. - Sergiy
  • 2
    Yes, I saw the picture ... delete the price field and create for the beginning a primary key on the id field, it has the right place. In general, the keys themselves do not appear, you should have indicated when adding a field that it is the primary key, so that it would become. And you also need to make a unique index / key on after href (you’d like to do an update based on it. Yes, and I would not recommend the Price double field, money cannot be stored in this type of data, it does not guarantee the complete accuracy of the number Use an appropriately sized decimal - Mike
  • one
    Lord, and the text is why it is. Use varchar and yes, specify at its creation the maximum length of which it can be - Mike
  • one
    I do not understand these pictures. you have written below that the primary id. Why there is something on the right that is not clear. I have no phpmyadmin on hand to see. if you need a penny, make a price (10.2). And just try to add two records with the same price, if added means in ok if not - then the field really became unique. - Mike Nov.

0