﻿<?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?)  » More control over ConnectionManager</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Sun, 31 May 2026 05:40:26 GMT</lastBuildDate><ttl>20</ttl><item><title>More control over ConnectionManager</title><link>http://forum.strataframe.net/FindPost22187.aspx</link><description>Hi,&lt;br&gt;
I have a few questions regarding connection manager. &lt;br&gt;
First I need to be able to "purge" all connections stored on user machine in Connections.dat.&lt;br&gt;
This is what I came up with so far:&lt;br&gt;
&lt;br&gt;
[codesnippet]&lt;br&gt;
        private static void PurgeConnections()&lt;br&gt;
        {&lt;br&gt;
            try&lt;br&gt;
            {&lt;br&gt;
                string connectionDat = Path.Combine(ConnectionManager.ConnectionDataFolder, "Connections.dat");&lt;br&gt;
                File.Delete(connectionDat);&lt;br&gt;
            }&lt;br&gt;
            catch&lt;br&gt;
            { }&lt;br&gt;
            &lt;br&gt;
        }&lt;br&gt;
[/codesnippet]&lt;br&gt;
&lt;br&gt;
Does this make sense?, or is there something within SF that I could use? Also my concern is when this code runs on the machine where loged user is not in admin or power user roles. Would this code work?&lt;br&gt;
&lt;br&gt;
Second, is there a way to write a new connection string to Connection.bat without calling .SetConnection or .ShowAvailableConnectionsWizard (i.e. without user interaction), my FS application reference other assemblies that manager their own connection strings, and I wont to be able to store them in ConnectionManager.&lt;br&gt;
&lt;br&gt;
Thanks&lt;br&gt;</description><pubDate>Fri, 06 Mar 2009 11:10:24 GMT</pubDate><dc:creator>Leonard P.</dc:creator></item><item><title>RE: More control over ConnectionManager</title><link>http://forum.strataframe.net/FindPost22236.aspx</link><description>[quote][b]Greg McGuffey (03/06/2009)[/b][hr]Wow, I didn't know that. That's very cool. :D[/quote]&lt;P&gt;Also a quick look at the dbeApplicationdData.vb will reveal all code needed to handle the XML file for things like the Server Settings for the Server Console application. :w00t:&lt;P&gt;Thanks Trent :hehe:</description><pubDate>Fri, 06 Mar 2009 11:10:24 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: More control over ConnectionManager</title><link>http://forum.strataframe.net/FindPost22235.aspx</link><description>Wow, I didn't know that. That's very cool. :D</description><pubDate>Fri, 06 Mar 2009 10:41:11 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: More control over ConnectionManager</title><link>http://forum.strataframe.net/FindPost22228.aspx</link><description>Well, you can talk to these files the same way that we do.&amp;nbsp; In the UI assembly there are two BOs that talk directly to the applicationkeys.dat and connection.dat files.&amp;nbsp; They wrap the encryption, etc.&amp;nbsp; So you could just create an instance of each to manipulate these files.&amp;nbsp;&lt;/P&gt;&lt;P&gt;[codesnippet]Dim app As New DbeApplicationData()&lt;BR&gt;Dim connections As New DbeConnectionData()&lt;BR&gt;'-- Retrieve the application key record to which the connections are tied&lt;BR&gt;app.FillWithActiveKey("MyApplicationKey")&lt;/P&gt;&lt;P&gt;If app.Count &amp;gt; 0 Then&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- Retrieve the connections&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; connections.FillAll(app.app_pk)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- At this point it is a BO...so you can add, remove, just like you would with any other BO&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- When ready to save, Call the SaveToXML method&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; connections.SaveToXML()&lt;BR&gt;End If[/codesnippet]</description><pubDate>Fri, 06 Mar 2009 09:33:56 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: More control over ConnectionManager</title><link>http://forum.strataframe.net/FindPost22198.aspx</link><description>[quote][b]Alex Luyando (03/04/2009)[/b]&lt;br&gt;
&lt;br&gt;
If the user is running multiple StrataFrame applications with different data sources this could be problematic, no?[/quote]&lt;br&gt;
&lt;br&gt;
That's a very good point Alex! Deleting connection.dat file just wiped out StrataFrame connection info on my dev machine. So, I had to reentered it again on VS .NET startup ;)</description><pubDate>Wed, 04 Mar 2009 14:08:39 GMT</pubDate><dc:creator>Leonard P.</dc:creator></item><item><title>RE: More control over ConnectionManager</title><link>http://forum.strataframe.net/FindPost22196.aspx</link><description>The connection strings don't get loaded into the connection store (connections.dat) when they are set directly via the DataLayer.DataSources.Add() method.  They shouldn't need to as it sounds like the connection strings are known by the various assemblies.  &lt;br&gt;
&lt;br&gt;
Also, a little background.  The ConnectionManager is really just a UI that allows the user to enter information that gets built into a connection string and then can store that connection string someplace (connections.dat) were it can be reused. The connections strings are stored by key, actually allowing multiple connections per type (so multiple apps can use the same file...so yes, deleting this file for one app would also delete the connections for other apps too, thus the user would have to reenter the connection info for those other apps).  Check out ConnectionManager.ShowAvailableConnectionStrings().&lt;br&gt;
&lt;br&gt;
The ConnectionManager then just uses the info to build the connection string and then add the data source using the exact same method you'd use to do it yourself (DataLayer.DataSources.Add()).  &lt;br&gt;
&lt;br&gt;
So, if your connection strings come from some place else, no need for ConnectionManager. It's job is to manage connection strings entered by the user...that's all.  Here are some possible sources for the connection string:&lt;br&gt;
&lt;br&gt;
- ConnectionManager prompts user for info, then uses the stored info next time the app opens.&lt;br&gt;
- Connection string is set directly via DataSources.Add()&lt;br&gt;
- Connection string is saved in a constant&lt;br&gt;
- Connection string is retrieved via a property of a class&lt;br&gt;
- Connection string is retrieved via a method of a class&lt;br&gt;
- Connection string is retrieved form the App.Config file&lt;br&gt;
- Connection string is retrieved from an XML file created using XmlBasics (SF tool)&lt;br&gt;
- Connection string is retrieved from a Windows service, via TCP&lt;br&gt;
- Connection string is retrieved from a web service&lt;br&gt;
- etc.&lt;br&gt;
&lt;br&gt;
In all cases, the connection string and a key are used to create the data source using DataLayer.DataSources.Add("key", "connection string").&lt;br&gt;
&lt;br&gt;
I'm guessing that you would just use the connection manager to handle a limited number of connections and then get the other connection strings via method calls in the various assemblies.&lt;br&gt;
&lt;br&gt;
You can allow the user to manage connections, by calling the ConnectionManager.ShowAvailableConnectionStrings().  They can add/remove connections as needed. I don't think there is a programmatic way to remove a connection though (and it would be hard, as the user actually can provide a name for the connection, which you wouldn't know).&lt;br&gt;
&lt;br&gt;
Hope that helps! :D</description><pubDate>Wed, 04 Mar 2009 13:42:34 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: More control over ConnectionManager</title><link>http://forum.strataframe.net/FindPost22194.aspx</link><description>[quote][b]Trent L. Taylor (03/04/2009)[/b][hr]This will work fine. They should already have permissions to this folder location anyway, so this should not be an issue.[/quote]&lt;br&gt;
&lt;br&gt;
Trent -&lt;br&gt;
&lt;br&gt;
If the user is running multiple StrataFrame applications with different data sources this could be problematic, no?</description><pubDate>Wed, 04 Mar 2009 13:20:29 GMT</pubDate><dc:creator>Alex Luyando</dc:creator></item><item><title>RE: More control over ConnectionManager</title><link>http://forum.strataframe.net/FindPost22193.aspx</link><description>[quote][codesnippet]' In SetDataSources, in AppMain.vb (program.cs)...&lt;br&gt;
Microfour.Strataframe.Data.DataLayer.DataSources.Add(New SqlDataSourceItem("key","Data Source=myserver...")[/codesnippet]&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
That make sense?&lt;br&gt;
&lt;br&gt;
[/quote]&lt;br&gt;
&lt;br&gt;
Yes, but from what I've seen (and I could've been doing something wrong) adding new datasource does not persist connection string to the connection store. &lt;br&gt;</description><pubDate>Wed, 04 Mar 2009 13:19:21 GMT</pubDate><dc:creator>Leonard P.</dc:creator></item><item><title>RE: More control over ConnectionManager</title><link>http://forum.strataframe.net/FindPost22190.aspx</link><description>The simple answer is no, ConnectionManager requires user interaction. Once the information is collected, it is placed in an encrypted XML file (connections.dat).  You might be able to pull this off...but you don't want to, there is a better way that isn't hard.&lt;br&gt;
&lt;br&gt;
For those connections that are not user configurable, just setup the datasources directly, via code:&lt;br&gt;
&lt;br&gt;
[codesnippet]' In SetDataSources, in AppMain.vb (program.cs)...&lt;br&gt;
Microfour.Strataframe.Data.DataLayer.DataSources.Add(New SqlDataSourceItem("key","Data Source=myserver...")[/codesnippet]&lt;br&gt;
&lt;br&gt;
You'd add a data source for every one you need. Likely, you'd reference the appropriate method in the assembly to get its connection string.  The "key" is then set on the BO so it knows were to get the data.&lt;br&gt;
&lt;br&gt;
That make sense?&lt;br&gt;
&lt;br&gt;</description><pubDate>Wed, 04 Mar 2009 12:57:29 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: More control over ConnectionManager</title><link>http://forum.strataframe.net/FindPost22189.aspx</link><description>Hi Trent, Thanks for Replying,&lt;br&gt;
&lt;br&gt;
Could you comment on the second part:&lt;br&gt;
&lt;br&gt;
[quote]Second, is there a way to write a new connection string to Connection.bat without calling .SetConnection or .ShowAvailableConnectionsWizard (i.e. without user interaction), my FS application reference other assemblies that manager their own connection strings, and I wont to be able to store them in ConnectionManager.[/quote]&lt;br&gt;
&lt;br&gt;
Thanks</description><pubDate>Wed, 04 Mar 2009 12:39:06 GMT</pubDate><dc:creator>Leonard P.</dc:creator></item><item><title>RE: More control over ConnectionManager</title><link>http://forum.strataframe.net/FindPost22188.aspx</link><description>This will work fine.&amp;nbsp; They should already have permissions to this folder location anyway, so this should not be an issue.</description><pubDate>Wed, 04 Mar 2009 12:25:10 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>