﻿<?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?)  » Share connection</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Mon, 08 Jun 2026 21:58:05 GMT</lastBuildDate><ttl>20</ttl><item><title>Share connection</title><link>http://forum.strataframe.net/FindPost21878.aspx</link><description>Hi,&lt;br&gt;
Is it possible to share connection for all / certain BOs to connect to DB?&lt;br&gt;
&lt;br&gt;
Thank you</description><pubDate>Wed, 11 Feb 2009 08:55:51 GMT</pubDate><dc:creator>Chan</dc:creator></item><item><title>RE: Share connection</title><link>http://forum.strataframe.net/FindPost21911.aspx</link><description>You changed it by executing a SQL command, correct?&amp;nbsp; You have to actually create a sql command object and execute it for that to take effect, like so:&lt;/P&gt;&lt;P&gt;[codesnippet]Dim cmd As New SqlCommand("SET TRANSACTION ISOLATION LEVEL READ UNCOMMITED")&lt;BR&gt;cmd.ExecuteNonQuery()[/codesnippet]&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Wed, 11 Feb 2009 08:55:51 GMT</pubDate><dc:creator>Dustin Taylor</dc:creator></item><item><title>RE: Share connection</title><link>http://forum.strataframe.net/FindPost21904.aspx</link><description>Hi,&lt;br&gt;
I have tried all IsolateLevel enum value while BusinessLayer.TransactionBegin, but no one help.&lt;br&gt;
Any ideas?&lt;br&gt;
&lt;br&gt;
Thank you</description><pubDate>Tue, 10 Feb 2009 19:52:28 GMT</pubDate><dc:creator>Chan</dc:creator></item><item><title>RE: Share connection</title><link>http://forum.strataframe.net/FindPost21895.aspx</link><description>Sorry, had a little typo on that reply. For the first option (forcing SQL to run the query even when&amp;nbsp;in the middle of a&amp;nbsp;transaction), you should run the following command after the query to return SQL to it's default settings:&lt;/P&gt;&lt;P&gt;[codesnippet]SET TRANSACTION ISOLATION LEVEL READ COMMITTED[/codesnippet]</description><pubDate>Tue, 10 Feb 2009 09:02:48 GMT</pubDate><dc:creator>Dustin Taylor</dc:creator></item><item><title>RE: Share connection</title><link>http://forum.strataframe.net/FindPost21894.aspx</link><description>Ah, now I get it :).&amp;nbsp; &lt;/P&gt;&lt;P&gt;By default SQL server will not let you read an uncommited transaction from a table. So when you are in the middle of a transaction, any queries to that table will block and wait for the transaction to commit before going through. This is SQL server functionality (not strataframe), and is working as designed, but there are two ways around it depending on your needs:&lt;/P&gt;&lt;P&gt;1) If you want to go ahead and run the query which will include the uncompleted transaction, you can set the isolation level of SQL to&amp;nbsp;READ UNCOMMITED before running the query, and the set it back to READ COMMITED after the query is run. This will run your query without blocking, but [i][b]will[/b][/i] include the incomplete transaction records. &lt;/P&gt;&lt;P&gt;So execute the following SQL command before running your query:&lt;/P&gt;&lt;P&gt;[codesnippet]SET TRANSACTION ISOLATION LEVEL READ UNCOMMITED[/codesnippet]&lt;/P&gt;&lt;P&gt;And when finished, execute this one:&lt;/P&gt;&lt;P&gt;[codesnippet]SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED[/codesnippet] &lt;/P&gt;&lt;P&gt;2) The second option is to leave the isolation level alone, but set the timeout on the query command to a longer value so that it will sit and wait for the transaction to complete before executing. This will include the [i][b]completed[/b][/i] transaction records, but could make the query appear to "hang" from an end user's perspective while it is waiting for the transaction to be completed (you could, of course, show a marquee thermometer or some such as part of the UI to let the user know it is processing.) &lt;/P&gt;&lt;P&gt;For this, you would just set the timeout parameter of your SQL command to a large value before executing it:&lt;/P&gt;&lt;FONT color=#008000 size=2&gt;&lt;FONT color=#008000 size=2&gt;&lt;P&gt;[codesnippet]'-- Create the command&lt;BR&gt;Dim cmd As SqlCommand = New SqlCommand("dbo.YourStoredProcedureOrQuery")&lt;BR&gt;'-- Increase the command timeout to 5 minutes&lt;BR&gt;cmd.CommandTimeout = 300[/codesnippet]&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;</description><pubDate>Tue, 10 Feb 2009 09:00:21 GMT</pubDate><dc:creator>Dustin Taylor</dc:creator></item><item><title>RE: Share connection</title><link>http://forum.strataframe.net/FindPost21891.aspx</link><description>Hi.&lt;br&gt;
thank you for reply,&lt;br&gt;
what I meant is connection object, the reason I ask this is because I have problem when query datab within transaction if that is any record saved to same table.&lt;br&gt;
for example, transaction began, bo a save data to table a, bo b try to query data of table a via new instance of bo a, error timeout occurred. &lt;br&gt;
&lt;br&gt;
any advise?&lt;br&gt;
thank you&lt;br&gt;</description><pubDate>Mon, 09 Feb 2009 21:32:32 GMT</pubDate><dc:creator>Chan</dc:creator></item><item><title>RE: Share connection</title><link>http://forum.strataframe.net/FindPost21885.aspx</link><description>I'm not sure if I understand your question completely, because your BOs shoud already be sharing the connection information.&amp;nbsp; &lt;/P&gt;&lt;P&gt;When you set up your project you will specify a default DbDataSourceItem in the SetDataSources() method of AppMain.vb (program.cs in C#).&amp;nbsp; The DbDataSourceItem is "default" when it has an empty DataSourceKey, which means that any business object will use that data source connection unless a different DataSourceKey if specified.&lt;/P&gt;&lt;P&gt;You can set up more than one database connection by adding a second DbDataSourceItem in SetDataSources(), you just have to give a unique string as the DataSourceKey for&amp;nbsp;the other&amp;nbsp;DbDataSourceItems.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[codesnippet]ConnectionManager.AddRequiredDataSourceItem("YourDataSourceKey", "SQL Connection", _&lt;BR&gt;&amp;nbsp;&amp;nbsp;DataSourceTypeOptions.SqlServer, "MyDatabase", "This connection is used by MyApplication.")[/codesnippet]&lt;/P&gt;&lt;P&gt;Is that what were asking, or did I miss the&amp;nbsp;point entirely? :)</description><pubDate>Mon, 09 Feb 2009 11:43:17 GMT</pubDate><dc:creator>Dustin Taylor</dc:creator></item><item><title>RE: Share connection</title><link>http://forum.strataframe.net/FindPost21883.aspx</link><description>I'm assuming your talking about connection pooling and not just sharing a data source.  ADO does this automatically. The connections do time out at around 5 min (this varies apparently quite a bit) if unused. They also close when you close the application.  This means that calling Close() on an open method doesn't actually close the connection.  The connection remains open within the connection pool.  This is turned on by default, so you'd have to figure out how to turn it off if you didn't want it. Try googling ADO connection pool for the details.</description><pubDate>Mon, 09 Feb 2009 11:31:56 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item></channel></rss>