﻿<?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 » Enhancement Requests  » Retain the existing db connection in a command object</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 03:46:31 GMT</lastBuildDate><ttl>20</ttl><item><title>Retain the existing db connection in a command object</title><link>http://forum.strataframe.net/FindPost23927.aspx</link><description>Hi,&lt;br&gt;
&lt;br&gt;
Just a thought....&lt;br&gt;
&lt;br&gt;
I recently had a need to populate just a single BO on a form from a different database to the other BO's on the form. The actual database to use isn't known until runtime.&lt;br&gt;
&lt;br&gt;
All our db access is via stored procedures in SQL Commands so, given that I had ready access to connection string I needed to use, I simply created SQL Connection, opened it and then set the SQL Commands .connection property. In tracking down why this didn't work I can see Business Layer creates a connection 'on-the-fly' and ignores what may already be there in the SQL Command object.&lt;br&gt;
&lt;br&gt;
I was wondering if it may be useful to check if a SQL Command object already has a connection object defined and use it rather than creating a 'standard connection'. The assumption here being that if a system has gone to the trouble of creating a connection and placing it in the SQL Command object then that's the connection that should be used.&lt;br&gt;
&lt;br&gt;
BTW - this is 'just a thought' - I have no need for this functionality as I have achieved the required results by other means.&lt;br&gt;
&lt;br&gt;
Cheers, Peter&lt;br&gt;</description><pubDate>Thu, 30 Jul 2009 08:01:50 GMT</pubDate><dc:creator>Peter Jones</dc:creator></item><item><title>RE: Retain the existing db connection in a command object</title><link>http://forum.strataframe.net/FindPost24002.aspx</link><description>LOL, I understand! :D</description><pubDate>Thu, 30 Jul 2009 08:01:50 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Retain the existing db connection in a command object</title><link>http://forum.strataframe.net/FindPost23997.aspx</link><description>&lt;br&gt;
so much to know, so little time...&lt;br&gt;
&lt;br&gt;
Thanks, Peter</description><pubDate>Wed, 29 Jul 2009 19:50:33 GMT</pubDate><dc:creator>Peter Jones</dc:creator></item><item><title>RE: Retain the existing db connection in a command object</title><link>http://forum.strataframe.net/FindPost23948.aspx</link><description>You can already do this one of several different ways.  First, you can create another data source key (which I don't think is what you need to do here) or you can just tell the BO to re-create the data layer, which will resolve this problem.  So if you change the connection string to an already existing data source and a BO instance already exists, then just call the RecreateDataLayer method on the BO.&lt;br&gt;
&lt;br&gt;
If this doesn't give you what you want, just dynamically create a new DataSource with a unique key, add it to the DataBasics.DataSources collection, set the DataSourceKey on the BO, and then you are good.  Remove it when done if necessary.</description><pubDate>Wed, 29 Jul 2009 09:39:52 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>