ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Core.Data Namespace / Database Class / Database Constructor / Database Constructor(DatabaseConnectionProperties)
The properties used to connect to an enterprise database.
Example

In This Topic
    Database Constructor(DatabaseConnectionProperties)
    In This Topic
    Opens an enterprise database with the specified connection properties. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax

    Parameters

    databaseConnectionProperties
    The properties used to connect to an enterprise database.
    Exceptions
    ExceptionDescription
    databaseConnectionProperties is null.
    A database-related exception has occurred.
    This object must be created within the lambda or delegate passed to QueuedTask.Run, or on a compatible STA thread.
    Example
    Opening an Enterprise Geodatabase using connection properties
    public async Task OpenEnterpriseGeodatabase()
    {
      await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
      {
        // Opening a Non-Versioned SQL Server instance.
        DatabaseConnectionProperties connectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer)
        {
          AuthenticationMode = AuthenticationMode.DBMS,
    
          // Where testMachine is the machine where the instance is running and testInstance is the name of the SqlServer instance.
          Instance = @"testMachine\testInstance",
    
          // Provided that a database called LocalGovernment has been created on the testInstance and geodatabase has been enabled on the database.
          Database = "LocalGovernment",
    
          // Provided that a login called gdb has been created and corresponding schema has been created with the required permissions.
          User = "gdb",
          Password = "password",
          Version = "dbo.DEFAULT"
        };
    
        using (Geodatabase geodatabase = new Geodatabase(connectionProperties))
        {
          // Use the geodatabase
        }
      });
    }
    
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also