473,320 Members | 2,110 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,320 software developers and data experts.

Q: Updating a single row

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
3 1336
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: pb648174 | last post by:
I have a single update statement that updates the same column multiple times in the same update statement. Basically i have a column that looks like .1.2.3.4. which are id references that need to...
2
by: Ray Holtz | last post by:
I have a form that shows a single record based on a query criteria. When I click a button it is set to use an append query to copy that record to a separate table, then deletes the record from the...
1
by: Ken | last post by:
Help! I have a MS Access database made up of a single table. The data updates for this database comes in the form of a single Excel spreadsheet, which is imported into the database table. I...
1
by: Prem | last post by:
Hi All I have a portal application that we have built that contains links to different modules. There is no static binding to these dlls from the application so that we can deploy some modules...
3
by: Doug | last post by:
Scenario: I select data from a SQL Server View which links 3 tables, into a single dataset table. I update some of those fields on a web form. When I want to update the db, clearly I can't update...
0
by: cwbp17 | last post by:
I'm having trouble updating individual datagrid cells. Have two tables car_master (columns include Car_ID, YEAR,VEHICLE) and car_detail (columns include Car_ID,PRICE,MILEAGE,and BODY);both tables...
0
by: jchavez | last post by:
When updating a column from a single row in a table from one server that is in replication with another server why doesn't the whole row update? Example Server 1 Table:CustomerInfo Columns: ...
5
by: =?Utf-8?B?U29tIE5hdGggU2h1a2xh?= | last post by:
i have data table containg 5000 rows to update it i am using foreach loop an updating very row with same value. buts its too slow.is there any way to update all the rows in single....
0
by: Mogrin | last post by:
So I have this windows .net form app, and I have the following goals: -Needs to be 1 single file, the executable, in any directory the user decides to download it to. No installation folder, no...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.