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.