Click here to Skip to main content
15,886,639 members
Home / Discussions / C#
   

C#

 
QuestionLinq2Sql cannot add an entity Pin
kenajelencres4-Sep-12 15:07
kenajelencres4-Sep-12 15:07 
QuestionRe: Linq2Sql cannot add an entity Pin
Eddy Vluggen4-Sep-12 21:45
professionalEddy Vluggen4-Sep-12 21:45 
AnswerRe: Linq2Sql cannot add an entity Pin
kenajelencres4-Sep-12 22:34
kenajelencres4-Sep-12 22:34 
GeneralRe: Linq2Sql cannot add an entity Pin
Eddy Vluggen4-Sep-12 22:44
professionalEddy Vluggen4-Sep-12 22:44 
GeneralRe: Linq2Sql cannot add an entity Pin
Pete O'Hanlon4-Sep-12 22:52
mvePete O'Hanlon4-Sep-12 22:52 
GeneralRe: Linq2Sql cannot add an entity Pin
kenajelencres4-Sep-12 23:49
kenajelencres4-Sep-12 23:49 
GeneralRe: Linq2Sql cannot add an entity Pin
Pete O'Hanlon4-Sep-12 23:53
mvePete O'Hanlon4-Sep-12 23:53 
GeneralRe: Linq2Sql cannot add an entity Pin
kenajelencres5-Sep-12 12:47
kenajelencres5-Sep-12 12:47 
wow that was a nice tip. tnx.

i did what you said and it turns out that IDNo is 1 because at the beginning of my code is
maxIndex = gradeyear.Count() -1;

and because i have only one record which i inserted using SQL management studio, maxIndex value is 0. and at the create new record
newGradeYear.IDNo = newGradeYear.IDNo = maxIndex + 1;

the value of maxIndex is 1 which will result in a duplicate. what i did is i took the value of textbox which has the correct value by using int32.parse. a new error appeared at the database.SubmitChanges():
Cannot insert explicit value for identity column in table 'GradeYear' when IDENTITY_INSERT is set to OFF


any suggestion to fix this?

i wonder why it worked on the tutorial i followed and not on mine when it is almost exactly the same code. D'Oh! | :doh:
GeneralRe: Linq2Sql cannot add an entity Pin
Pete O'Hanlon5-Sep-12 20:13
mvePete O'Hanlon5-Sep-12 20:13 
QuestionStart pages for beginners Pin
mauricemcse4-Sep-12 8:59
mauricemcse4-Sep-12 8:59 
AnswerRe: Start pages for beginners Pin
Eddy Vluggen4-Sep-12 9:03
professionalEddy Vluggen4-Sep-12 9:03 
QuestionRTD help at C# Pin
yatici4-Sep-12 7:39
yatici4-Sep-12 7:39 
AnswerRe: RTD help at C# Pin
Karl Sanford4-Sep-12 9:28
professionalKarl Sanford4-Sep-12 9:28 
GeneralRe: RTD help at C# Pin
yatici4-Sep-12 10:08
yatici4-Sep-12 10:08 
AnswerRe: RTD help at C# Pin
Eddy Vluggen4-Sep-12 22:00
professionalEddy Vluggen4-Sep-12 22:00 
QuestionC# proxy class Pin
sc steinhayse4-Sep-12 6:52
sc steinhayse4-Sep-12 6:52 
AnswerRe: C# proxy class Pin
Pete O'Hanlon4-Sep-12 7:03
mvePete O'Hanlon4-Sep-12 7:03 
GeneralRe: C# proxy class Pin
sc steinhayse4-Sep-12 12:29
sc steinhayse4-Sep-12 12:29 
GeneralRe: C# proxy class Pin
Pete O'Hanlon4-Sep-12 22:06
mvePete O'Hanlon4-Sep-12 22:06 
QuestionHow to do architecture design? Pin
yu-jian4-Sep-12 5:56
yu-jian4-Sep-12 5:56 
AnswerRe: How to do architecture design? Pin
Pete O'Hanlon4-Sep-12 5:59
mvePete O'Hanlon4-Sep-12 5:59 
AnswerRe: How to do architecture design? Pin
Eddy Vluggen4-Sep-12 6:04
professionalEddy Vluggen4-Sep-12 6:04 
GeneralRe: How to do architecture design? Pin
yu-jian4-Sep-12 6:30
yu-jian4-Sep-12 6:30 
GeneralRe: How to do architecture design? Pin
Eddy Vluggen4-Sep-12 6:47
professionalEddy Vluggen4-Sep-12 6:47 
AnswerRe: How to do architecture design? Pin
jschell4-Sep-12 11:51
jschell4-Sep-12 11:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.