By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,815 Members | 1,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,815 IT Pros & Developers. It's quick & easy.

Q: Updating a single row

P: n/a
Hi

Using code like:

dataAdaptor1.Update(dataSet1.Table("MyTable"))

it is possible to update a datasource with all the rows in MyTable.

What is the code to update a certain row in MyTable?

Thanks in advance

Geoff
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Geoff,
DataAdapter.Update is overloaded to accept a DataSet, a DataTable, or an
array of DataRows, to update a single row I would put the single row in an
array by itself, then call Update with this array.

Something like:
Dim rows() As DataRow
' do something to fill the rows array with a single row
rows = dataSet1.Table("MyTable").Select(...)
dataAdaptor1.Update(rows)

For example I have a project that uses:

Dim rows() As DataRow
' do something to fill the rows array with a single row
rows = dataSet1.Table("MyTable").Select(Nothing, Nothing,
DataViewRowState.Added)
dataAdaptor1.Update(rows)
Which will cause all the added rows in my datatable to be deleted from the
database, without effecting the Deleted or Modified rows. I then do the
Modified rows, followed by the Deleted rows.

Hope this helps
Jay

"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40*********************@news.dial.pipex.com.. .
Hi

Using code like:

dataAdaptor1.Update(dataSet1.Table("MyTable"))

it is possible to update a datasource with all the rows in MyTable.

What is the code to update a certain row in MyTable?

Thanks in advance

Geoff

Nov 20 '05 #2

P: n/a
Many thanks Jay

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:uj**************@TK2MSFTNGP09.phx.gbl...
Geoff,
DataAdapter.Update is overloaded to accept a DataSet, a DataTable, or an
array of DataRows, to update a single row I would put the single row in an
array by itself, then call Update with this array.

Something like:
Dim rows() As DataRow
' do something to fill the rows array with a single row
rows = dataSet1.Table("MyTable").Select(...)
dataAdaptor1.Update(rows)

For example I have a project that uses:

Dim rows() As DataRow
' do something to fill the rows array with a single row
rows = dataSet1.Table("MyTable").Select(Nothing, Nothing,
DataViewRowState.Added)
dataAdaptor1.Update(rows)
Which will cause all the added rows in my datatable to be deleted from the
database, without effecting the Deleted or Modified rows. I then do the
Modified rows, followed by the Deleted rows.

Hope this helps
Jay

"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40*********************@news.dial.pipex.com.. .
Hi

Using code like:

dataAdaptor1.Update(dataSet1.Table("MyTable"))

it is possible to update a datasource with all the rows in MyTable.

What is the code to update a certain row in MyTable?

Thanks in advance

Geoff


Nov 20 '05 #3

P: n/a
Doh!

I hate changing samples in mid stream. :-)
rows = dataSet1.Table("MyTable").Select(Nothing, Nothing,
DataViewRowState.Added) Which will cause all the added rows in my datatable to be deleted from the Should read "which will cause all the added rows in my datatable to be added
to the database".

Jay

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:uj**************@TK2MSFTNGP09.phx.gbl... Geoff,
DataAdapter.Update is overloaded to accept a DataSet, a DataTable, or an
array of DataRows, to update a single row I would put the single row in an
array by itself, then call Update with this array.

Something like:
Dim rows() As DataRow
' do something to fill the rows array with a single row
rows = dataSet1.Table("MyTable").Select(...)
dataAdaptor1.Update(rows)

For example I have a project that uses:

Dim rows() As DataRow
' do something to fill the rows array with a single row
rows = dataSet1.Table("MyTable").Select(Nothing, Nothing,
DataViewRowState.Added)
dataAdaptor1.Update(rows)
Which will cause all the added rows in my datatable to be deleted from the
database, without effecting the Deleted or Modified rows. I then do the
Modified rows, followed by the Deleted rows.

Hope this helps
Jay

"Geoff Jones" <ge***@NODAMNSPAM.com> wrote in message
news:40*********************@news.dial.pipex.com.. .
Hi

Using code like:

dataAdaptor1.Update(dataSet1.Table("MyTable"))

it is possible to update a datasource with all the rows in MyTable.

What is the code to update a certain row in MyTable?

Thanks in advance

Geoff


Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.