﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Further Weirdness with DB2 Transactional Save</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 09:27:52 GMT</lastBuildDate><ttl>20</ttl><item><title>Further Weirdness with DB2 Transactional Save</title><link>http://forum.strataframe.net/FindPost12292.aspx</link><description>I don't know how I do it, but I think I can find the strangest bugs and always at the last minute. :)&lt;br&gt;
&lt;br&gt;
I had everything built and had completed my QA testing. Everything functioned great, the BrokenRule issue was resolved. So, I moved all my files into the staging area. It's just a different directory on the same server, same hard drive. I set up a second QC/staging Web site and started clicking through to make sure permissions were all set up and working the way they did on the development site and I had some more issues.&lt;br&gt;
&lt;br&gt;
As I said, this is on the same server and the same hard drive, just a different file path. I made sure all my config values were updated to use the new path for logging and database login information (still connects to the same database, but accesses a file in a different path location). It logs in, gets me data and works fine. When I try to save something, for example, modified application permissions for a role, it blows up.&lt;br&gt;
&lt;br&gt;
I finally tracked it down to it claiming the transaction key didn't exist. I double checked and it starts the transaction. I added some code to conditionally use the transaction if it exists. So I check the Transactions collection for the key and if it exists, I tell the business object to save using the transaction. If it doesn't, I have it save without a transaction. It detects that there is a transaction and then throws an exception that the key does not exist.  Here's the stack trace:&lt;br&gt;
&lt;br&gt;
[quote]at MicroFour.StrataFrame.Business.BusinessLayer.Save(Boolean Transactional, String TransactionKey)&lt;br&gt;
   at Payless.Sourcing.MaterialsManagement.Admin.Permissions.cmdSave_Click(Object sender, ImageClickEventArgs e) in I:\PSS Design\Visual Studio\Materials Management\MM_UI\Administration\permissions.aspx.cs:line 218[/quote]&lt;br&gt;
&lt;br&gt;
And here's the Exception and Inner Exception that get thrown:&lt;br&gt;
&lt;br&gt;
[quote]EXCEPTION: An error occurred while saving the data to the server.&lt;br&gt;
INNER EXCEPTION: Save cannot continue because a transaction with the key [PermissionsUpdate] has not been started.[/quote]&lt;br&gt;
&lt;br&gt;
I'm thoroughly confused about this one since it all works fine and lets me save in the development area, but not in the QC area. They reference the same Strataframe assemblies and the same IBM.Data.DB2 assembly. It was just a straight copy of the files from one directory (D:\Dev\Application\) to another (D:\QC\Application).&lt;br&gt;
&lt;br&gt;
Any ideas what could be causing this?&lt;br&gt;
&lt;br&gt;
Thanks!</description><pubDate>Thu, 08 Nov 2007 14:35:43 GMT</pubDate><dc:creator>PeterA</dc:creator></item><item><title>RE: Further Weirdness with DB2 Transactional Save</title><link>http://forum.strataframe.net/FindPost12585.aspx</link><description>Good deal :)</description><pubDate>Thu, 08 Nov 2007 14:35:43 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Further Weirdness with DB2 Transactional Save</title><link>http://forum.strataframe.net/FindPost12557.aspx</link><description>[quote][b]Trent L. Taylor (11/07/2007)[/b][hr]When it is created, it is just going to fire the normal component events. The only custom event that gets fired at creation time is the ParentFormLoading which will not fire if it is created in code. The events related to the BO are going to be once the object is created. I am not very clear on your question so I don't know if that is what you were looking for or not. :ermm:[/quote]&lt;br&gt;
&lt;br&gt;
That answers my question. I was after whether ParentFormLoading fired when it was created in the background. I just had a cryptic way of getting there. :D&lt;br&gt;
&lt;br&gt;
Thanks!</description><pubDate>Thu, 08 Nov 2007 07:11:04 GMT</pubDate><dc:creator>PeterA</dc:creator></item><item><title>RE: Further Weirdness with DB2 Transactional Save</title><link>http://forum.strataframe.net/FindPost12546.aspx</link><description>When it is created, it is just going to fire the normal component events.&amp;nbsp; The only custom event that gets fired at creation time is the ParentFormLoading which will not fire if it is created in code.&amp;nbsp; The events related to the BO are going to be once the object is created.&amp;nbsp; I am not very clear on your question so I don't know if that is what you were looking for or not. :ermm:</description><pubDate>Wed, 07 Nov 2007 17:48:00 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Further Weirdness with DB2 Transactional Save</title><link>http://forum.strataframe.net/FindPost12530.aspx</link><description>I should probably qualify that question. What events are fired off [i]on the business object[/i] when it's created in the background? :) I realized there were a couple different ways to answer that right after I clicked "Post". :-).</description><pubDate>Wed, 07 Nov 2007 11:10:46 GMT</pubDate><dc:creator>PeterA</dc:creator></item><item><title>RE: Further Weirdness with DB2 Transactional Save</title><link>http://forum.strataframe.net/FindPost12529.aspx</link><description>[quote][b]Ben Chase (11/07/2007)[/b][hr]Yep, that about sums it up :)&lt;br&gt;
&lt;br&gt;
Glad you got it working.[/quote]&lt;br&gt;
&lt;br&gt;
Me, too. :)&lt;br&gt;
&lt;br&gt;
New question, now (though related in a very roundabout way). :) What events are fired off when you create a business object on the fly (i.e. in the background when its going to be filled and used to populate a DropDownList)?</description><pubDate>Wed, 07 Nov 2007 11:09:03 GMT</pubDate><dc:creator>PeterA</dc:creator></item><item><title>RE: Further Weirdness with DB2 Transactional Save</title><link>http://forum.strataframe.net/FindPost12518.aspx</link><description>Yep, that about sums it up :)&lt;/P&gt;&lt;P&gt;Glad you got it working.</description><pubDate>Wed, 07 Nov 2007 09:19:44 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Further Weirdness with DB2 Transactional Save</title><link>http://forum.strataframe.net/FindPost12510.aspx</link><description>[quote][b]Ben Chase (11/06/2007)[/b][hr]Aha, that's the problem... the transaction is owned by the data source... it's not static. So, the transaction has to be started on the data source that is being used by the business object, not just on any data source. There are wrapper methods on the BusinessLayer class that can start the transactions, so you might try to use one of those:&lt;br&gt;
&lt;br&gt;
BusinessLayer.TransactionBegin(this.someBo.DataSourceKey, "TranKey");[/quote]&lt;br&gt;
&lt;br&gt;
I changed the code to look like this:&lt;br&gt;
&lt;br&gt;
[quote]&lt;br&gt;
// Start the transaction&lt;br&gt;
if (!DataLayer.DataSources[Authorization.DataSourceKey].Transactions.ContainsKey("PermissionsUpdate"))&lt;br&gt;
{&lt;br&gt;
    SqlHandler.Tracer.LogMessage("Starting transaction: PermissionsUpdate", TraceLevel.Verbose);&lt;br&gt;
    BusinessLayer.TransactionBegin(Authorization.DataSourceKey, IsolationLevel.ReadUncommitted);&lt;br&gt;
}&lt;br&gt;
[/quote]&lt;br&gt;
&lt;br&gt;
It corrected the problem. I believe I understand why, now. Essentially, because I had put the connection into it's own container (the mySqlh property), the transaction starts/stops I called there really didn't have an effect on the DataLayer the business objects used. Does that about sum it up?&lt;br&gt;
&lt;br&gt;
Thanks!&lt;br&gt;</description><pubDate>Wed, 07 Nov 2007 07:50:29 GMT</pubDate><dc:creator>PeterA</dc:creator></item><item><title>RE: Further Weirdness with DB2 Transactional Save</title><link>http://forum.strataframe.net/FindPost12477.aspx</link><description>Aha, that's the problem... the transaction is owned by the data source... it's not static.&amp;nbsp; So, the transaction has to be started on the data source that is being used by the business object, not just on any data source.&amp;nbsp; There are wrapper methods on the BusinessLayer class that can start the transactions, so you might try to use one of those:&lt;/P&gt;&lt;P&gt;BusinessLayer.TransactionBegin(this.someBo.DataSourceKey, "TranKey");</description><pubDate>Tue, 06 Nov 2007 09:06:04 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Further Weirdness with DB2 Transactional Save</title><link>http://forum.strataframe.net/FindPost12462.aspx</link><description>[quote][b]Ben Chase (11/05/2007)[/b][hr]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?[/quote]&lt;br&gt;
&lt;br&gt;
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.&lt;br&gt;
&lt;br&gt;
[quote][b]Ben Chase (11/05/2007)[/b][hr]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.[/quote]&lt;br&gt;
&lt;br&gt;
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.&lt;br&gt;
&lt;br&gt;
Here's the code where I start it:&lt;br&gt;
&lt;br&gt;
[quote]&lt;br&gt;
// Start the transaction&lt;br&gt;
if (!mySqlh.Transactions.ContainsKey("PermissionsUpdate"))&lt;br&gt;
{&lt;br&gt;
    SqlHandler.Tracer.LogMessage("Starting transaction: PermissionsUpdate", TraceLevel.Verbose);&lt;br&gt;
    mySqlh.TransactionBegin("PermissionsUpdate", IsolationLevel.ReadUncommitted);&lt;br&gt;
}&lt;br&gt;
[/quote]&lt;br&gt;
&lt;br&gt;
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.&lt;br&gt;
&lt;br&gt;
Thanks!&lt;br&gt;</description><pubDate>Mon, 05 Nov 2007 15:15:47 GMT</pubDate><dc:creator>PeterA</dc:creator></item><item><title>RE: Further Weirdness with DB2 Transactional Save</title><link>http://forum.strataframe.net/FindPost12411.aspx</link><description>You say that you initialize the DataSourceKey on the business objects from the value in the config file... How are you initializing it?&amp;nbsp; Are you just setting the value in the constructor, or some other way?&amp;nbsp; 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").&amp;nbsp; 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.</description><pubDate>Mon, 05 Nov 2007 08:56:09 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Further Weirdness with DB2 Transactional Save</title><link>http://forum.strataframe.net/FindPost12330.aspx</link><description>Just wanted to know if there'd been any progress on confirming the problem. This particular bug makes it impossible for me to connect to multiple databases from one application.&lt;br&gt;
&lt;br&gt;
Thanks!&lt;br&gt;
&lt;br&gt;
Peter</description><pubDate>Thu, 01 Nov 2007 07:54:27 GMT</pubDate><dc:creator>PeterA</dc:creator></item><item><title>RE: Further Weirdness with DB2 Transactional Save</title><link>http://forum.strataframe.net/FindPost12293.aspx</link><description>Well, I discovered I'd made one difference in the config file. Sorry, I thought everything was the same, but it's still a little strange.&lt;br&gt;
&lt;br&gt;
The Dev version didn't have a DataSourceKey specified and the QC version did. Basically, this is just a value that I use throughout the application as the key to my datasource. I initialize all the business objects to use it when the application is started and I reference it as my connection as well. Why would it have a problem when a DataSourceKey is specified to something other than an empty string and not with an empty string?&lt;br&gt;
&lt;br&gt;
Thanks!</description><pubDate>Tue, 30 Oct 2007 15:46:31 GMT</pubDate><dc:creator>PeterA</dc:creator></item></channel></rss>