M
Mark Baldwin
I am using SQL2000 and .NET 2.0
I have a dataset, with two DataTables each having a TableAdapter. I need to
use the insert command on the first TableAdapter and then execute a stored
procedure on the second table adapter - all within a transaction.
Now I want to use datasets, because they auto generate the code which is
exactly the same as I intend to manually create anyway and they have the
advantage that I can quickly refresh them if any columns change etc
All of my database operations are in stored procedures in the server, but
accessed through the TableAdapter.
Problem is that each TableAdapter uses it's own connection. I have tried
creating my own connection and transaction and assigning the connection to
the TableAdapter but I just get an error when executing a stored
procedure...
[System.InvalidOperationException] = {"ExecuteScalar requires the command to
have a transaction when the connection assigned to the command is in a
pending local transaction. The Transaction property of the command has not
been initialized."}
Anyway, I have tried to wrap these operations in a TransactionScope but this
promotes to a DTC transaction with SQL2000 which isn't acceptable.
Surely there is straightforward way in which you can utilize datasets to
load data from the database and then tableadapters to run any operations
through predetermind stored procedures.
Any help much appreciated...
Mark
I have a dataset, with two DataTables each having a TableAdapter. I need to
use the insert command on the first TableAdapter and then execute a stored
procedure on the second table adapter - all within a transaction.
Now I want to use datasets, because they auto generate the code which is
exactly the same as I intend to manually create anyway and they have the
advantage that I can quickly refresh them if any columns change etc
All of my database operations are in stored procedures in the server, but
accessed through the TableAdapter.
Problem is that each TableAdapter uses it's own connection. I have tried
creating my own connection and transaction and assigning the connection to
the TableAdapter but I just get an error when executing a stored
procedure...
[System.InvalidOperationException] = {"ExecuteScalar requires the command to
have a transaction when the connection assigned to the command is in a
pending local transaction. The Transaction property of the command has not
been initialized."}
Anyway, I have tried to wrap these operations in a TransactionScope but this
promotes to a DTC transaction with SQL2000 which isn't acceptable.
Surely there is straightforward way in which you can utilize datasets to
load data from the database and then tableadapters to run any operations
through predetermind stored procedures.
Any help much appreciated...
Mark