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.
Never mind. I tried using the Geoprocessing tool and it's doing the same thing as my code.
Were you able to connect to your SQL Server this way? Mine is not working. It says connected successfully but it's not (no connections made on the server side).