master-detail Update problem


Easy & Urgent
i am try to update simple master-detail form ... idid try this Code :

        Me.Validate()
        Me.PI_OrderHeaderBindingSource.EndEdit()
        Me.PI_OrderHeaderTableAdapter.Update(Me.DataSet1.PI_OrderHeader)

' whitch is generated by Designer

but it dose not update my 2 tables

i did try this code :

        Me.Validate()
        Me.PI_OrderHeaderBindingSource.EndEdit()
        Me.PI_OrderDetBindingSource.EndEdit()

        Me.PI_OrderDetDataGridView.EndEdit()

        If DataSet1.HasChanges Then
            DataSet1.PI_OrderDet.AcceptChanges()
            DataSet1.PI_OrderHeader.AcceptChanges()
            DataSet1.AcceptChanges()
            'Me.PI_OrderHeaderTableAdapter.Update(Me.DataSet1.PI_OrderHeader)

            PI_OrderHeaderTableAdapter.Update(DataSet1.PI_OrderHeader)
            PI_OrderDetTableAdapter.Update(DataSet1.PI_OrderDet)
        End If

with this code there is no error ... and there is nothing in my 2 table

i did check there is new data in the dataSet ... but why this wont updated 2 the database

may be this help :

Master Table

OrderNo     Int  Identity column [PK]
OrderDate  Date
...

Detail Table

OrderNo    Int
ItemNo      Int
LVL 6
hatem72Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hatem72Author Commented:


i found out what i am missing here

i have to AcceptChanges after the update the DataSet ... Not before
0
RobertRFreemanCommented:
Note:  You should not use AcceptChanges at all.
The adapter will automatically call AcceptChanges as part of the update.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hatem72Author Commented:


hi RobertRFreeman

thanx for ur advice ... but i did read this [ Using AcceptChanges ] somewhere with the update
    [ still learning ]
i was close to go back to vb6 becuase of this problem ... i stuck there for weeks

any way thank god again ... and for ur advice u well have the points
0
RobertRFreemanCommented:
:)

Note on AcceptChanges:
The datatable keeps track of the RowState for each row in the table.  EX: Inserted, Modified, Deleted, Unchanged.
The Adapter.Update uses the rowstate to know whether the row has changed and if so, what Command to execute.
(Inserted = InsertCommand, Modified = UpdateCommand, Deleted = DeleteCommand).
After updating each row, the Adapter.Update sets the RowState back to Unchanged (via AcceptChanges).

The DataRow also keeps a copy of the last Unchanged version of itself, so if you want to Undo changes, you can call RejectChanges on the row.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.