I am having an issue with linq2sql data connector not updating the data object when I call Submit Changes
I have this code on a button click event, Though it is failing because it is setting Index to 1( which exists in the db) – not 3 as I have assigned in the object
I started getting a DuplicateKetException was unhandled, and if I view the details I see the object has old data in it ( Index = 1,Model = blah,Service = blah)
What am I doing wrong, is there some cache I need to flush???
public void button_Add_Click(object sender, RoutedEventArgs e)
{
using (DataClasses1DataContext dc = new DataClasses1DataContext());
{
Equipment equip = new Equipment
{
Index = 3,
Model = “ABCD1234",
Service = DateTime.Now
};
//Add the new object to the equip collection.
dc.Equipments.InsertOnSubmit(equip);
//Submit the change to the database.
dc.SubmitChanges();
}
//catch (Exception e)
{
//Console.WriteLine(e);
dc.SubmitChanges();
}
}