Update datarow in typed dataset

  • Thread starter C a r l o s A n t o n i o
  • Start date
C

C a r l o s A n t o n i o

Hello,

How can I update a datarow in a typed dataset? It seems i can't make it to
write the changes into the database. What am i doing wrong? Thanks in
advance.

Here's my code:

Private Sub save_changes(ByVal _infraction_id As System.Guid)

Dim o_adapter As New roswellDataSetTableAdapters.infractionsTableAdapter

Dim o_data_table As roswellDataSet.infractionsDataTable

Dim o_row As roswellDataSet.infractionsRow



o_data_table = o_adapter.GetData

o_row = o_data_table.FindByinfraction_id(_infraction_id)



With o_row

..BeginEdit()

.ticket_number = "333"

.EndEdit()

.AcceptChanges()

End With



o_adapter.Update(o_data_table)

o_data_table.AcceptChanges()

End Sub
 
S

Steve

Remove the calls to AcceptChanges(), both on the row and the table. It's
only needed after the Update(), and even then, it's automatically
"accepted".


Steve C.
MCAD,MCSE,MCP+I,CNE,CNA,CCNA
 
C

Cor Ligthert[MVP]

Carlos,

To explain what acceptchanges does.

It is probably one of the most confusing words Microsoft ever made for a
method. (We see your problem here thousands times).

"Acceptchanges" is needed when you don't update the datatable to the
database using a dataadapter, or update a copy of the datatable and than
have to set the changes as updated in the original datatable.

Standard are only rows updated by a dataadapter which changes the updated
rows to done and removes all the information about the previous state (It is
set with the changes in it as the new changes to not changed).

I am always currious what brainwave the team had who invented this word for
this. It was in Redmond, there drugs are not as free as here I understood,
so the change it was that, is low.

Cor

..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top