Run SQL against DataView Object

A

acoles

Hi,

I have a requirement in a current project to show the effect of a
particular SQL Statement on a given database table.

The statement will only effect one row but could be an UPDATE, DELETE
or an INSERT command. The user should see the table row before and
after for an UPDATE, a new row for an INSERT and the row to be removed
for a DELETE command. I intend to represent a copy of the table before
and after the query has been run (without affecting the database) as a
DataView object.

Does anyone know whether there is any built in functionality for
executing raw SQL statements against ADO.NET objects?

My current plan (not find anything more suitable) involves creating a
function which would parse the SQL statement as a string and determine
the target table and the type of query (it would always start with
either INSERT, DELETE or UPDATE). It would then locate the WHERE
clause which could easily be applied to a DataView of the table.

Has anyone else ever come across something like this before? I am
relatively new to .NET and am not sure whether they would be a more
elequent/faster approach. Any views would be greatly appreciated! I
am writing the application in C# although that is probably irrelevant
here.

Thanks!

Andrew
 
P

Patrice

Nothing out of the box but I've heard about third party libraries being able
to do this.

You may want also to explain what you are trying to do (for example the
datatable keeps AFAIK original values, you perhaps don't need to keep your
own copy).

If this is to show the effect for pedagogic purpose but don't update you
could also just send the query to a "true" database, select the modified row
and rollback the transaction...
 

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