<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Store Database Connection String in App.config for an ArcGIS Pro SDK Add-In 2.x in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/store-database-connection-string-in-app-config-for/m-p/842426#M3912</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have added an app.config file to my visual studio pro SDK project and I’m trying to retrieve a connection string from it. The retrieval code always returns null. I don’t know if that’s because it is a UserControl or running inside ArcGIS Pro or what. Any thoughts? Is there a better place to store the connection string?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Visual Studio 2017, .Net Framework 4.6.1, ArcGIS Pro SDK 2.1, SQL Server&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;app.config&lt;/P&gt;&lt;P&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;&lt;BR /&gt; &amp;lt;configuration&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;connectionStrings&amp;gt; &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;add name="my_conn" connectionString="Data Source=xx.xx.xx.xxx;Initial Catalog=some_db;User ID=xxx;Password=yyy" /&amp;gt; &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/connectionStrings&amp;gt; &lt;BR /&gt; &amp;lt;/configuration&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;c# code&lt;/P&gt;&lt;P&gt;// Assume failure.&lt;BR /&gt; string returnValue = null;&lt;/P&gt;&lt;P&gt;// Look for the name in the connectionStrings section.&lt;BR /&gt; ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["my_conn"];&lt;/P&gt;&lt;P&gt;// If found, return the connection string.&lt;BR /&gt; if (settings != null)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; returnValue = settings.ConnectionString;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 19 Mar 2018 18:35:30 GMT</pubDate>
    <dc:creator>BillMacPherson</dc:creator>
    <dc:date>2018-03-19T18:35:30Z</dc:date>
    <item>
      <title>Store Database Connection String in App.config for an ArcGIS Pro SDK Add-In 2.x</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/store-database-connection-string-in-app-config-for/m-p/842426#M3912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have added an app.config file to my visual studio pro SDK project and I’m trying to retrieve a connection string from it. The retrieval code always returns null. I don’t know if that’s because it is a UserControl or running inside ArcGIS Pro or what. Any thoughts? Is there a better place to store the connection string?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Visual Studio 2017, .Net Framework 4.6.1, ArcGIS Pro SDK 2.1, SQL Server&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;app.config&lt;/P&gt;&lt;P&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&amp;gt;&lt;BR /&gt; &amp;lt;configuration&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;connectionStrings&amp;gt; &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;add name="my_conn" connectionString="Data Source=xx.xx.xx.xxx;Initial Catalog=some_db;User ID=xxx;Password=yyy" /&amp;gt; &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;lt;/connectionStrings&amp;gt; &lt;BR /&gt; &amp;lt;/configuration&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;c# code&lt;/P&gt;&lt;P&gt;// Assume failure.&lt;BR /&gt; string returnValue = null;&lt;/P&gt;&lt;P&gt;// Look for the name in the connectionStrings section.&lt;BR /&gt; ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["my_conn"];&lt;/P&gt;&lt;P&gt;// If found, return the connection string.&lt;BR /&gt; if (settings != null)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; returnValue = settings.ConnectionString;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Mar 2018 18:35:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/store-database-connection-string-in-app-config-for/m-p/842426#M3912</guid>
      <dc:creator>BillMacPherson</dc:creator>
      <dc:date>2018-03-19T18:35:30Z</dc:date>
    </item>
  </channel>
</rss>

