ArcGIS Pro Add-In SDK C# Issue: Create SQL Server database connection connects to different database

275
1
01-14-2022 06:09 AM
JadedEarth
New Contributor III

I'm using ArcGIS Pro version 2.9 and Visual Studio 2019 C# language.

I have an Add-In app that creates a SQL Server database connection. Problem is it connects to
a different database even though I specified the actual database name.

Code snippet:

 

 

private void ConnectToSQLServerDb()
{
    try
    {
        string outFolder = E:\WorkingFolder\MyAddIn;
	string outName = "MGConnection.sde";

	var args = Geoprocessing.MakeValueArray(outFolder, outName, "SQL SERVER", "ServerInstance", "OPERATING_SYSTEM_AUTH", "MGDatabase");
	var gp_result = Geoprocessing.ExecuteToolAsync("CreateDatabaseConnection_management", Geoprocessing.MakeValueArray(args.ToArray()));


	ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Finished creating database connection: ", "Result", MessageBoxButton.OK, MessageBoxImage.Information);
    }
    catch (Exception ex)
    {
	ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Failed to create database connection: " + ex.Message, "Error Message", MessageBoxButton.OK, MessageBoxImage.Error);
    }
} 

 

 

 

Appreciate any help.

0 Kudos
1 Reply
JadedEarth
New Contributor III

Never mind.  I tried using the Geoprocessing tool and it's doing the same thing as my code.

0 Kudos