I am trying to record unique identifiers, so I cannot afford to have a duplicate record of my ID's
I am getting an error that looks like this when I try to update my SQL Server table called Clients
.
Violation of PRIMARY KEY constraint 'PK_clients'. Cannot insert
duplicate key in object 'db_owner.clients'.
The code for this looks like so:
public void Subscribe(string clientID, Uri uri)
{
clientsDBDataContext clientDB = new clientsDBDataContext();
var client = new ServiceFairy.clientURI();
client.clientID = clientID;
client.uri = uri.ToString();
clientDB.clientURIs.InsertOnSubmit(client);
clientDB.SubmitChanges();
}
Any Idea how I can go about fixing this, so I can update my rows, all I want to be able to do is when a row exists then only update the associated URI, and if it doesn't exist to submit a new clientID + URI,
Thanks
John
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…