I think what I'm trying to do is something relatively simple. I have
created a DataTable using the SQLDataAdapter.Fill method:
Dim da As New SqlDataAdapter("SELECT * FROM Trans", cn)
Dim ds As New DataSet
da.Fill(ds, "AllTrans")
I am currently editing the table records individually by selecting a
subset of the data using a DataView and using the DataRowView.BeginEdit
and DataRowView.EndEdit methods. For example:
Dim dv As New DataView(ds.Tables("AllTrans"))
dv.RowFilter = "A1 = 'ABC'"
Dim drv As DataRowView
For Each drv In dv
drv.BeginEdit()
drv("S1") = "NC"
drv.EndEdit()
Next
However I would like to instead update the DataSet using the equivalent
of an update statement, e.g. "UPDATE AllTrans SET S1 = 'NC' WHERE A1 =
'ABC'".
I am not trying to update the original data source.
Thanks.
Miha Markic [MVP C#] - 05 Jul 2005 17:26 GMT
Hi,
No, there is no such functionality in ado.net.
I think someone posted a notice in this newsgroup about a product that
supports sql statements over DataSet few days or weeks ago.

Signature
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
SLODUG - Slovene Developer Users Group www.codezone-si.info
>I think what I'm trying to do is something relatively simple. I have
> created a DataTable using the SQLDataAdapter.Fill method:
[quoted text clipped - 23 lines]
>
> Thanks.
Rick - 05 Jul 2005 18:01 GMT
Thanks Miha. It's unfortunate that it can't be done through ado.net.
Cor Ligthert [MVP] - 05 Jul 2005 17:35 GMT
Skyjoker,
This looks strange to me, why are you not just getting a datatable that you
have to update using a "where" clause in the Select. Seems for me much
easier and cost much less time on the server, on the used network and in the
used computer..
Just my thought,
Cor
Rick - 05 Jul 2005 19:01 GMT
Hi Cor,
I'm currently doing it this way because I have numerous updates that I
want to do to the data, based on more complex criteria. I want to end
up with one DataTable that contains all of the original data with the
various updates applied.
Cor Ligthert [MVP] - 05 Jul 2005 21:24 GMT
Rick,
However what do you think that the processing behind the scene will be with
that SQL select command that you propose.
It will probably be very much less efficient as what you are doing now.
Just my thought,
Cor
Nilesh.Desh - 06 Jul 2005 16:39 GMT
Use case in select statement, it will make your code more efficient.
SELECT Case WHEN A1 = 'ABC' THEN 'NC' ELSE A1 END as A1
FROM Trans
This way you don't have to update the datatable.
Thanks
Nilesh
Steve Gerrard - 06 Jul 2005 02:05 GMT
>I think what I'm trying to do is something relatively simple. I have
> created a DataTable using the SQLDataAdapter.Fill method:
[quoted text clipped - 23 lines]
>
> Thanks.
Maybe you can write yourself a sub, something like
UpdateTable(DTable, Filter, FieldName, NewValue)
with the same code structure you have above.
If there was such a SQL function for a DataTable, it would be doing essentially
the same thing.