Execute SQL statement on Dataset

G

Guest

Hi,

Is there a way to execute SQL statement on a Dataset?

For example, my Dataset contains 1 table and I want to execute the following
SQL statement:

UPDATE table1 SET Field1='x' WHERE Field2='y'

I know I can use filter and loop on the rows but I have many SQL statements
I'ld like to reuse them.

Thanks,
 
W

William \(Bill\) Vaughn

This is irrelevant Scott. By executing an UPDATE against a table, he implied
that the operation would change all of the rows specified by the WHERE
clause. While you can use the "Select" method/property against a table, to
find a subset of the rows, this will not permit one to execute an action
against all of those rows--not without visiting each one.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
S

Scott M.

While you can use the "Select" method/property against a table, to find a
subset of the rows, this will not permit one to execute an action against
all of those rows--not without visiting each one.

So, is this not a way to do it? The question was "Is there a way to execute
SQL statement on a Dataset?" The Select method allows for a SQL type of
criteria to be used. Granted it must be accompanied by DataTable techniques
for row movement, it does allow for SQL type statements to be used in
conjunction with a DataTable.

I was responding to Marina who said "You can't do anything like that." .
You most certainly can.
 
V

Val Mazur \(MVP\)

This Select is more like a WHERE clause. After selection you would need to
loop through the rows, but it definitely helps to limit rows to work with

--
Val Mazur
Microsoft MVP

http://xport.mvps.org
 
S

Scott M.

Yes, I know. But it does give you SQL "like" capabilities with a DataTable
and that's the point I was making.
 
C

Cor Ligthert

Pierrev,

A dataset is when it is not in memory nothing more than a flat file that has
to be processed completly serialized.

Things as append with a text file, or using a file let say binary on disk is
completly impossible with it. Therefore things as Update are absolute
something that is impossible.

I hope this gives an idea.

Cor
 
M

Marina

I said you cannot execute update statements on a dataset like that. And you
cannot do that!

There are obviously ways to accomplish that. But I assumed the original
question was regarding literally executing SQL statements on the dataset -
which is not possible.
 

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