473,404 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Update datarow in typed dataset

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.infractionsTableAdapte r

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
Aug 21 '07 #1
3 2928
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 a r l o s A n t o n i o wrote:
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.infractionsTableAdapte r

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

Aug 21 '07 #2
C a r l o s,

Don't call AcceptChanges on the datarow.

Kerry Moorman
"C a r l o s A n t o n i o >" wrote:
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.infractionsTableAdapte r

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
Aug 21 '07 #3
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

..
"C a r l o s A n t o n i o >" <carlvazpr?arrobażyahoo.comschreef in
bericht news:%2****************@TK2MSFTNGP03.phx.gbl...
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.infractionsTableAdapte r

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

Aug 22 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mojtaba Faridzad | last post by:
Hi, Please check these lines: DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet, "mytable"); DataRow row; row = dataSet.Tables.Rows; row.BeginEdit(); row = "555";
7
by: Steve B. | last post by:
Does anyone know why the DA Update() would throw an exception? I moved the database but I updated the Conn and the DA, currently (trying)removing/replacing DS. Is there a another direction I...
0
by: Doug | last post by:
I've got a strongly-typed dataset with 2 related tables in it ("Staff" and "Roles"). I want to make a change to the parent Staff row and also to its child Role row. I'm having difficulty figuring...
4
by: CaptRR | last post by:
I think this is the right group to post to, so here goes. My problem is this, I cannot update the datarow to save my life. Been on this for 2 days now, and still am no closer to figuring it out...
9
by: jaYPee | last post by:
I have search a lot of thread in google newsgroup and read a lot of articles but still i don't know how to update the dataset that has 3 tables. my 3 tables looks like the 3 tables from...
5
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I...
2
by: travhale | last post by:
in a new project using .net 2005, c#. getting err message "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." source RDBMS is oracle 8i. I add a new...
3
by: =?Utf-8?B?THVib21pcg==?= | last post by:
Hi, I have a DataGridView that displays data from one table from database. I didn’t implement any my code, I just used wizard to do all the work with DatagridView populating. Visual Studio...
3
by: Fred Chateau | last post by:
Any obvious reason here why data is not being loaded into the database? SqlDataAdapter dataAdapter = new SqlDataAdapter(sqlCommand); SqlCommandBuilder commandBuilder = new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.