Ben Chase (11/05/2007)
You say that you initialize the DataSourceKey on the business objects from the value in the config file... How are you initializing it? Are you just setting the value in the constructor, or some other way?I have a method in the Global.asax file that I call during the Page_Init event. It takes a parameter of type ApplicationBasePage (pass in "this" as the parameter value) and set the data source keys on all the objects that way.
Ben Chase (11/05/2007)
Most likely, it seems that the transaction is being started on the wrong data source (say the tran is getting started for data source "", while the business object is expecting it to be started for data source "MyDataSource"). Check the place where you call TransactionBegin() and make sure that you're using the data source key from your config file to start the transaction.That was what I started to think might be the problem, but I've only got one data source object that I'm using. Also during Page_Init I assign a value of type Db2DataSourceItem to a page-level object attribute (mySqlh). I call the TransactionBegin off this object. It's worked fine on all my other pages (starting the transaction on the same page-level object attribute), it's only on this one page that I seem to be having a problem. It's very strange.
Here's the code where I start it:
// Start the transaction
if (!mySqlh.Transactions.ContainsKey("PermissionsUpdate"))
{
SqlHandler.Tracer.LogMessage("Starting transaction: PermissionsUpdate", TraceLevel.Verbose);
mySqlh.TransactionBegin("PermissionsUpdate", IsolationLevel.ReadUncommitted);
}
I don't think there's much I can really screw up on it and I've used this same method all through my application. As I said, it's just on this one page.
Thanks!