DAAB - Enterprise Library

A

Antonio Paglia

Does somebody know how to Update a Table (Dataset) without using Stored
Procedure. I'm using in-line SQL with Oracle.

Dim db As Database = DatabaseFactory.CreateDatabase()
dbCommandWrapper = db.GetSqlStringCommandWrapper(MySelectCommand)
mDataSet = New DataSet("MyTable")
mDataSet = db.ExecuteDataSet(dbCommandWrapper) ' return a dataset
......
' makes changes to data

Dim rowsAffected As Integer = db.UpdateDataSet(mDataSet, "MyTable",
InsertCommand, UpdateCommand, DeleteCommand , UpdateBehavior.Standard)

How can I create my InsertCommand, UpdateCommand and DeleteCommand ???

I don't want to OracleCommandBuilder because this is dependent of Oracle
Provider.

Any help will be appreciated
TIA
Antonio
 
C

Cor Ligthert [MVP]

Antonio,

The most easiest thing (until 2003) is to open a new component and than to
use the Oracledataadapter. That opens a wizard that creates those for you.
In 2005 you can do it as well however have than in it is in a dataset (which
has than in my opinion nicer readable commands).

I hope this helps,

Cor
 
G

Guest

If you want to go complete generic, you are best to simply forego performance
and use OleDb providers. If this is not your preferred option, create a
wrapper (DatabaseHelper?) that doles out the work based on configuration
information. You need a more generic way of sending in parameters, however. I
have done this with a Hashtable in the past, in the format of:

ht.Add(parameterName, Value);

You then create a matching algorithm for each type of provider and create
correct parameter objects for the type fo database.

You can also go all the way up to the ADO.NET interfaces.

No matter which road you take, you have a bit of work ahead of you.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
A

Antonio Paglia

I have tried to do this. I Create a wrapper with an update method. Here
open a Connection and init Transaction using DAAB commands. Then create a
OracleDataAdapter using :

db.GetConnection.ConnectionString as last parameter.



I believe that this open a new connection outside the context of the
previous connection. When Rollback is executed, the data have been
commited.

Dim db As Database = DatabaseFactory.CreateDatabase()

connection = db.GetConnection()
connection.Open()
transaction = connection.BeginTransaction()

Dim OraDataAdapter As System.Data.OracleClient.OracleDataAdapter

OraDataAdapter = New OracleClient.OracleDataAdapter("SELECT *
FROM " & TableName, db.GetConnection.ConnectionString)

Dim Oracb As New
OracleClient.OracleCommandBuilder(OraDataAdapter)
OraDataAdapter.InsertCommand = Oracb.GetInsertCommand
OraDataAdapter.UpdateCommand = Oracb.GetUpdateCommand

OraDataAdapter.Update(mDataTable)

transaction.Rollback()
connection.Close()
connection = Nothing

Any suggestion I will appreciate.

TIA

Antonio
 

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