none
I can´t create, update or delete because i don´t have a principal key RRS feed

  • Question

  • Hello, i tried the example of msdn for modify data (http://msdn.microsoft.com/en-us/library/bb907191.aspx) and it works well whit Northwind database, but i tried the same whit a database i made and i had the following error in  .InsertOnSubmit(...):

    "Can not execute operations Create, Update or Delete on 'Table (mytable)' because you do not have a primary key."

    I have the first column of the table assigned as primary key.

    I don´t know what happens.

    Thank you
    Monday, July 6, 2009 8:52 PM

Answers

All replies

  • Ensure that the primary key column is marked as primary key in the Linq-to-SQL designer. (There's a property on columns/class members that tells L2S if they're part of the primary key or not)


    Kristofer - Huagati Systems Co., Ltd. - Cool tools for Linq-to-SQL and Entity Framework: www.huagati.com/dbmltools (VS designer add-in), www.huagati.com/L2SProfiler (query profiler for L2S)
    Tuesday, July 7, 2009 12:46 AM
    Answerer
  • it works fine, thanks!

    I have another questions that i dont know if it could be here:

    I tried to connect whit my database whit LinQtoSql from a Microsoft Web Developer ASP.NET aplication but i obtain this error in my webpage:

    "An attempt to attach an auto-named database for file C:\Archivos de programa\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\CSRbase.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."

    I´m using a IIS server in my computer.

    I can acces this database perfectly from a Visual Basic Express local aplication but whit a Web Developer aplication not.

    greetings

    Tuesday, July 7, 2009 2:38 PM
  • I was trying and have seen that the database only work in my Web Developer Aplication if i attached it to the project (a copy), but if i do this the changes only occurs in the copy of the database on the project, and the original base in the SQL Server Express don´t change.

    if i work whitout attach a database copy (whit the original directly), i obtain the error in the post above.
    Tuesday, July 7, 2009 6:29 PM

  • "An attempt to attach an auto-named database for file C:\Archivos de programa\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\CSRbase.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."



    From the top of my head, that is usually caused by file permissions.
    Kristofer - Huagati Systems Co., Ltd. - Cool tools for Linq-to-SQL and Entity Framework: www.huagati.com/dbmltools (VS designer add-in), www.huagati.com/L2SProfiler (query profiler for L2S)
    Wednesday, July 8, 2009 3:22 AM
    Answerer