<?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 Re: Best practice for establishing SDE Connection once in session for ArcGIS Pro Add-in? in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/best-practice-for-establishing-sde-connection-once/m-p/1247087#M9272</link>
    <description>&lt;P&gt;I'm not sure I understand the question. &amp;nbsp;You could read the connection string from a registry key or configuration file or something like that (please don't store a password there&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;).&lt;/P&gt;&lt;P&gt;There's no problem connecting to a single&amp;nbsp;geodatabase multiple times through the Pro SDK. The underlying code will share a single connection.&lt;/P&gt;&lt;P&gt;--Rich&lt;/P&gt;</description>
    <pubDate>Tue, 10 Jan 2023 23:35:50 GMT</pubDate>
    <dc:creator>RichRuh</dc:creator>
    <dc:date>2023-01-10T23:35:50Z</dc:date>
    <item>
      <title>Best practice for establishing SDE Connection once in session for ArcGIS Pro Add-in?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/best-practice-for-establishing-sde-connection-once/m-p/1246908#M9268</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm developing an add-in with a range of tools and many of them access our SDE database (mostly for reading but sometimes writing). I've been told I should only access it once per session but I'm wondering if there's any examples on the best practice for this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently I've separated it out into a "Data" class, but my implementation feels overcomplicated because I want it to use a different connection string based on the development or production build. Does anyone have any guidance here? Any examples in the documentation?&lt;/P&gt;&lt;P&gt;Here's my current Data class:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public static class Data
    {
        private static DatabaseConnectionProperties _dbConnectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.Oracle)
        {
            AuthenticationMode = AuthenticationMode.DBMS,
            User = GetCredential("user"),
            Password = GetCredential("password"),
            Instance = GetCredential("instance")
        };
        public static DatabaseConnectionProperties dbConnectionProperties
        {
            get { return _dbConnectionProperties; }
        }

        private static Geodatabase _sdeGeodatabase = new Geodatabase(_dbConnectionProperties);
        public static Geodatabase SDEGeodatabase
        {
            get =&amp;gt; _sdeGeodatabase;
        }

        private static string GetCredential(string credential)
        {
            DbConnectionStringBuilder dbConnectionStringBuilder = new DbConnectionStringBuilder();
            dbConnectionStringBuilder.ConnectionString = Settings.ConnectionString;
            if (credential == "user") return dbConnectionStringBuilder["User ID"].ToString();
            if (credential == "password") return dbConnectionStringBuilder["Password"].ToString();
            if (credential == "instance") return dbConnectionStringBuilder["Data Source"].ToString();
            return null;
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2023 17:55:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/best-practice-for-establishing-sde-connection-once/m-p/1246908#M9268</guid>
      <dc:creator>succip</dc:creator>
      <dc:date>2023-01-10T17:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: Best practice for establishing SDE Connection once in session for ArcGIS Pro Add-in?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/best-practice-for-establishing-sde-connection-once/m-p/1247087#M9272</link>
      <description>&lt;P&gt;I'm not sure I understand the question. &amp;nbsp;You could read the connection string from a registry key or configuration file or something like that (please don't store a password there&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;).&lt;/P&gt;&lt;P&gt;There's no problem connecting to a single&amp;nbsp;geodatabase multiple times through the Pro SDK. The underlying code will share a single connection.&lt;/P&gt;&lt;P&gt;--Rich&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2023 23:35:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/best-practice-for-establishing-sde-connection-once/m-p/1247087#M9272</guid>
      <dc:creator>RichRuh</dc:creator>
      <dc:date>2023-01-10T23:35:50Z</dc:date>
    </item>
  </channel>
</rss>

