﻿<?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 » WinForms (How do I?)  » Retrieving connection string without using ConnectionManager</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Wed, 16 Sep 2026 02:32:51 GMT</lastBuildDate><ttl>20</ttl><item><title>Retrieving connection string without using ConnectionManager</title><link>http://forum.strataframe.net/FindPost13649.aspx</link><description>A little background...&lt;/P&gt;&lt;P&gt;1) I am using click once deployment, and I do not want the user to see the database setup wizard.&lt;/P&gt;&lt;P&gt;2) because of #1, I have to use&amp;nbsp;&lt;FONT color=#008080 size=2&gt;DataLayer&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;.DataSources.Add to add my database connection&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;3) The main application (Program.cs) runs many other SF forms.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;4) Some of these SF forms read data directly (do not use BO's)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#000000&gt;so far so good?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;Question:&amp;nbsp;How can I create s SQLConnection and pass it the ConnectString without using ConnectionManager to get it?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#000000&gt;i.e.how can I get the connection string from the datalayer? I really don't want to code the connectstring in all of my forms that need it when not using the BO to get the data.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;I know this is probably so obvious it's stupid, but....&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;Thanks in advance.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;Doug&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Wed, 23 Jan 2008 09:27:37 GMT</pubDate><dc:creator>Doug Birtell</dc:creator></item><item><title>RE: Retrieving connection string without using ConnectionManager</title><link>http://forum.strataframe.net/FindPost13678.aspx</link><description>Bill ! ! !&lt;/P&gt;&lt;P&gt;That's &lt;STRONG&gt;exactly&lt;/STRONG&gt; what I was looking for.&amp;nbsp; Worked perfectly.&amp;nbsp; &lt;/P&gt;&lt;P&gt;Trent,&lt;/P&gt;&lt;P&gt;I'll look forward to seeing your example on using the BBS in reporting.&amp;nbsp; Maybe I'm just too used to doing things the old fashioned way&lt;/P&gt;&lt;P&gt;Thanks for all the help!&lt;/P&gt;&lt;P&gt;Doug</description><pubDate>Wed, 23 Jan 2008 09:27:37 GMT</pubDate><dc:creator>Doug Birtell</dc:creator></item><item><title>RE: Retrieving connection string without using ConnectionManager</title><link>http://forum.strataframe.net/FindPost13654.aspx</link><description>That's it, Bill..good answer.&amp;nbsp; Also, Doug, I thought I would mention that you can use a BusinessBindingSOurce as the data source fora&amp;nbsp; report.&amp;nbsp; This is how we do our reports within our medical software.&amp;nbsp; In fact, I am hoping to release a sample that shows how to use Report-Shooter with a BBS.&amp;nbsp;</description><pubDate>Tue, 22 Jan 2008 17:10:49 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Retrieving connection string without using ConnectionManager</title><link>http://forum.strataframe.net/FindPost13652.aspx</link><description>Sure.&amp;nbsp; That makes sense.&amp;nbsp; After re-reading the initial post, I can see where I misunderstood you.&amp;nbsp; Sorry about that.&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;MicroFour.StrataFrame.Data.&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;DataLayer&lt;/FONT&gt;&lt;FONT size=2&gt;.DataSources[&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"MyDB"&lt;/FONT&gt;&lt;FONT size=2&gt;].ConnectionString;&lt;/P&gt;&lt;/FONT&gt;&lt;P&gt;Hope that helps,&lt;BR&gt;Bill</description><pubDate>Tue, 22 Jan 2008 16:49:39 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: Retrieving connection string without using ConnectionManager</title><link>http://forum.strataframe.net/FindPost13651.aspx</link><description>Bill,&lt;/P&gt;&lt;P&gt;I understand what you are saying, and that is exactly what I have done.&amp;nbsp; The problem is that I have a menu form that calls multiple SF Maintenance forms as well as SF standard forms that run reports.&amp;nbsp; These "report" forms do not make use of the BO's, thus, I need to use SQLCommand to retrieve data based on how a form is filled out.&amp;nbsp; I have not figured out how to create the SQLCommand object, which needs the SQLConnect string, which is in the program.cs.&amp;nbsp;(without using the ConnectionManager)&amp;nbsp;I did not want to duplicate the connect string in all of the report forms.&amp;nbsp; Does that all make sense?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Doug</description><pubDate>Tue, 22 Jan 2008 16:40:40 GMT</pubDate><dc:creator>Doug Birtell</dc:creator></item><item><title>RE: Retrieving connection string without using ConnectionManager</title><link>http://forum.strataframe.net/FindPost13650.aspx</link><description>[quote][b]Doug Birtell (01/22/2008)[/b][hr] &lt;P&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;Question:&amp;nbsp;How can I create s SQLConnection and pass it the ConnectString without using ConnectionManager to get it?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;[/quote]&lt;/P&gt;&lt;P&gt;Hi Doug,&lt;/P&gt;&lt;P&gt;Here is what I did.&amp;nbsp; I commented out everything in the ConnectionManger section, then I created each data source manually.&amp;nbsp; Like this:&lt;/P&gt;&lt;FONT color=#2b91af size=2&gt;&lt;P&gt;DataLayer&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;.DataSources.Add(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;SqlDataSourceItem&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"MyDB"&lt;/FONT&gt;&lt;FONT color=#000000 size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"Data Source=DBSERVER;Initial Catalog=MyReallyCoolDB;User ID=sa;Password=pwd;Asynchronous Processing=True"&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#000000&gt;));&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#7777bb size=2&gt;I have one of these entries for every connection that I may use in the application.&amp;nbsp; This is the only place that they show up.&amp;nbsp; I also have each BO's DataSourceKey pointing to one of these data sources (DataSourceKey=MyDB).&amp;nbsp; Depending on which primary BO is used on a given form the form will utilize that connection string.&amp;nbsp; Of course, you could do more work to grab these strings from an external source (e.g.&amp;nbsp;encrypted file), but I have left them right in my program.cs file.&amp;nbsp; All has worked quite well, so far.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Hope that helps,&lt;BR&gt;Bill</description><pubDate>Tue, 22 Jan 2008 16:32:33 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item></channel></rss>