How can I check if a specific primary key (a string variable) already exists on the table and if not insert a new record otherwise just update the existing one with new values using c#?
I tried this
MySqlCommand cmd2 = new MySqlCommand("INSERT INTO mapdisplay
(ID,Distance)
VALUES
(@r,@c,)
ON DUPLICATE KEY UPDATE mapdisplay
(Distance)
VALUES
(@c,)", conn);
but I think the syntax is wrong.
Look at the last example in this link:
http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html