Click here to Skip to main content
15,895,798 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionCreating Multi-user db application Pin
Gagan.2029-Aug-11 4:25
Gagan.2029-Aug-11 4:25 
AnswerRe: Creating Multi-user db application Pin
ekolis29-Aug-11 8:32
ekolis29-Aug-11 8:32 
AnswerRe: Creating Multi-user db application Pin
Wayne Gaylard29-Aug-11 21:53
professionalWayne Gaylard29-Aug-11 21:53 
AnswerRe: Creating Multi-user db application Pin
Bert Mitton30-Aug-11 6:02
professionalBert Mitton30-Aug-11 6:02 
QuestionScreening programmers skills Pin
MadMax201128-Aug-11 22:40
MadMax201128-Aug-11 22:40 
AnswerRe: Screening programmers skills Pin
DaveAuld28-Aug-11 23:58
professionalDaveAuld28-Aug-11 23:58 
AnswerRe: Screening programmers skills Pin
Eddy Vluggen29-Aug-11 6:36
professionalEddy Vluggen29-Aug-11 6:36 
Questionproblems add new record on entity framework Pin
dcode2528-Aug-11 12:32
dcode2528-Aug-11 12:32 
Hello !
i have a sql server 2008r2 database ( stu) with a table (st) with these columns :
stID - identity (int autoincrement value)
name - char(10)
com - char(20)

i have a project in vb.net 2010 , and i have generated entity framework model with the database.
I have a form with a listbox and 2 textbox , and 2 buttons Addrecord and Saverecord.
The listbox is bound with an object from entity (stBindingSource) and displayMember: name , Valuememeber : stID. The form is also binded with stbindingsource. ( textbox1:name , Textbox2: com)
I want to add new record.The code is :
……-----------------------------------
Dim stu As stuEntities

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
stu= New stuEntities

stBindingSource.DataSource = stu.sts
End Sub
---------------------------------------------
Private Sub Addrecord_Click(sender As System.Object, e As System.EventArgs) Handles Addrecord.Click
stBindingSource.AddNew()
End Sub
-------------------------------------------------
Private Sub Saverecord_Click(sender As System.Object, e As System.EventArgs) Handles Saverecord.Click
stBindingSource.EndEdit
stu.SaveChanges(System.Data.Objects.SaveOptions.None)

End Sub

So ,first i click to "Addrecord" , and after i fill the 2 textbox , i click Saverecord.
The first record is saved with no problem.If a add another record , the record is saved , but when I open the table on database , the first record is saved 2 times , the second record is saved 1 time.
I try to add 3,4… records and everytime the last record is saved 1 time the others are all duplicated

If I call stu.SaveChanges() , with no parametres , I can’t add any records because I get an error :
The changes to the database were committed successfully, but an error occurred while updating the object context. The ObjectContext might be in an inconsistent state. Inner exception message: AcceptChanges cannot continue because the object's key values conflict with another object in the ObjectStateManager. Make sure that the key values are unique before calling AcceptChanges.
Please help me.

Thank you.

modified on Monday, August 29, 2011 9:41 PM

QuestionParsing XML in VB.NET using XMLDocument Pin
Jaggernaut28-Aug-11 12:01
Jaggernaut28-Aug-11 12:01 
AnswerRe: Parsing XML in VB.NET using XMLDocument Pin
Eddy Vluggen29-Aug-11 6:29
professionalEddy Vluggen29-Aug-11 6:29 
GeneralRe: Parsing XML in VB.NET using XMLDocument Pin
Jaggernaut29-Aug-11 23:11
Jaggernaut29-Aug-11 23:11 
QuestionSliding effect issue in VB.NET Pin
Razanust26-Aug-11 17:15
Razanust26-Aug-11 17:15 
AnswerRe: Sliding effect issue in VB.NET Pin
Simon_Whale27-Aug-11 22:10
Simon_Whale27-Aug-11 22:10 
QuestionDataset or Entity Framework ? Pin
progal2225-Aug-11 5:16
progal2225-Aug-11 5:16 
AnswerRe: Dataset or Entity Framework ? Pin
Dave Kreskowiak25-Aug-11 5:21
mveDave Kreskowiak25-Aug-11 5:21 
GeneralRe: Dataset or Entity Framework ? Pin
progal2225-Aug-11 5:41
progal2225-Aug-11 5:41 
GeneralRe: Dataset or Entity Framework ? Pin
Simon_Whale25-Aug-11 5:45
Simon_Whale25-Aug-11 5:45 
GeneralRe: Dataset or Entity Framework ? Pin
progal2225-Aug-11 5:54
progal2225-Aug-11 5:54 
GeneralRe: Dataset or Entity Framework ? Pin
Dave Kreskowiak25-Aug-11 7:08
mveDave Kreskowiak25-Aug-11 7:08 
GeneralRe: Dataset or Entity Framework ? Pin
progal2225-Aug-11 8:41
progal2225-Aug-11 8:41 
GeneralRe: Dataset or Entity Framework ? Pin
Dave Kreskowiak25-Aug-11 9:55
mveDave Kreskowiak25-Aug-11 9:55 
GeneralRe: Dataset or Entity Framework ? Pin
progal2226-Aug-11 4:49
progal2226-Aug-11 4:49 
GeneralRe: Dataset or Entity Framework ? Pin
Dave Kreskowiak26-Aug-11 5:16
mveDave Kreskowiak26-Aug-11 5:16 
QuestionCreating resolution independent applications in VB.NET Pin
Razanust24-Aug-11 8:26
Razanust24-Aug-11 8:26 
AnswerRe: Creating resolution independent applications in VB.NET Pin
MicroVirus24-Aug-11 17:48
MicroVirus24-Aug-11 17:48 

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.