Cannot insert row into SQL 2005 express edition database using LinqI am getting the error &quot;Can't perform Create, Update or Delete operations on 'Table(Flight)' because it has no primary key.&quot; <div><br/></div> <div>When the user clicks in the button on my form I want to insert a new row into my database. The database is called reservations.</div> <div>I am using the code from MSDN on how to insert a column using LINQ. This is my code:</div> <div><br/></div> <div> <pre lang=x-vbnet> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim database As New Airline.ReservationsDataClassesDataContext Dim fl As New Airline.Flight fl.ID = GetSelectedId2() fl.Date = DateTextBox.Text fl.ItemName = ItemNameTextBox.Text fl.Price = PriceTextBox.Text database.Flights.InsertOnSubmit(fl) database.SubmitChanges() End Sub</pre> I am at a dead end. Please let me know if you have any suggestions or need additional information. I do have the primary key of this table's identity property set to &quot;yes&quot; and I have it set to auto increment.</div> <div><br/></div> <div>Thanks.</div>© 2009 Microsoft Corporation. All rights reserved.Fri, 03 Jul 2009 01:43:14 Z76aff295-55ca-4c31-8bcd-eeb85376c0e0http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/76aff295-55ca-4c31-8bcd-eeb85376c0e0#76aff295-55ca-4c31-8bcd-eeb85376c0e0http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/76aff295-55ca-4c31-8bcd-eeb85376c0e0#76aff295-55ca-4c31-8bcd-eeb85376c0e0wolferenehttp://social.msdn.microsoft.com/Profile/en-US/?user=wolfereneCannot insert row into SQL 2005 express edition database using LinqI am getting the error &quot;Can't perform Create, Update or Delete operations on 'Table(Flight)' because it has no primary key.&quot; <div><br/></div> <div>When the user clicks in the button on my form I want to insert a new row into my database. The database is called reservations.</div> <div>I am using the code from MSDN on how to insert a column using LINQ. This is my code:</div> <div><br/></div> <div> <pre lang=x-vbnet> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim database As New Airline.ReservationsDataClassesDataContext Dim fl As New Airline.Flight fl.ID = GetSelectedId2() fl.Date = DateTextBox.Text fl.ItemName = ItemNameTextBox.Text fl.Price = PriceTextBox.Text database.Flights.InsertOnSubmit(fl) database.SubmitChanges() End Sub</pre> I am at a dead end. Please let me know if you have any suggestions or need additional information. I do have the primary key of this table's identity property set to &quot;yes&quot; and I have it set to auto increment.</div> <div><br/></div> <div>Thanks.</div>Fri, 26 Jun 2009 19:30:35 Z2009-06-26T19:30:35Zhttp://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/76aff295-55ca-4c31-8bcd-eeb85376c0e0#c206ef5d-4ca3-4b6a-a379-24e6d9a9dc44http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/76aff295-55ca-4c31-8bcd-eeb85376c0e0#c206ef5d-4ca3-4b6a-a379-24e6d9a9dc44Roahn Luohttp://social.msdn.microsoft.com/Profile/en-US/?user=Roahn%20LuoCannot insert row into SQL 2005 express edition database using LinqHello,<br/><br/>I'm a little confused with the data table you use, is it named Flight or Flights? The error message indicates that we are operating the Talbe Flight, while in the code, we actually access the Flights table which may map to the Flight table in the database, you may find the definition of those two objects in the .dbml file and to see if they are matched. If we re-add the Flight/Flights table, how about the issue?<br/><br/>Also, I recommend you post thread in our <a href="http://social.msdn.microsoft.com/Forums/en-US/linqtosql/threads">Linq to SQL forum</a> for more help.<br/><br/>Best regards,<br/> <hr class=sig> Please remember to mark the replies as answers if they help and unmark them if they provide no help.<br/>If you have any feedback, please tell us.<br/>Welcome to the <a href="http://cfx.codeplex.com">All-In-One Code Framework!</a>Tue, 30 Jun 2009 05:54:08 Z2009-06-30T05:55:52Zhttp://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/76aff295-55ca-4c31-8bcd-eeb85376c0e0#70e88d07-13e4-4cb6-89cb-e48623b08852http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/76aff295-55ca-4c31-8bcd-eeb85376c0e0#70e88d07-13e4-4cb6-89cb-e48623b08852wolferenehttp://social.msdn.microsoft.com/Profile/en-US/?user=wolfereneCannot insert row into SQL 2005 express edition database using LinqTHANKS! I checked my dtml file and sure enough it was using the wrong table... not even sure where it was pulling it from :( oh well, I got it straightend out. Thanks for pointing me in the right direction.Thu, 02 Jul 2009 22:46:17 Z2009-07-02T22:46:17Z