Skip to main content
.NET Framework 4.5.2+

XafApplication.ConnectionString Property

Specifies the connection string used to connect to the application’s database or to the Application Server.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.1.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public string ConnectionString { get; set; }

Property Value

Type Description
String

The connection string.

Remarks

Your application may have different connection strings for different scenarios (for example, a specific string for each compilation mode). When you create a new XAF application, the Solution Wizard generates the connection strings for Microsoft SQL Server Express LocalDB. To customize the autogenerated connection strings or create a new string, open the application configuration file and navigate to its connectionStrings section. For more information, refer to the following help topic: Connect an XAF Application to a Database Provider.

The XafApplication.ConnectionString property allows you to choose a specific connection string for your application. The following example demonstrates how to specify this property for a WinForms application:

static class Program {
   static void Main() {
      //...
      MySolutionWindowsFormsApplication application = new MySolutionWindowsFormsApplication();
      application.ConnectionString = 
         ConfigurationManager.ConnectionStrings["ConnectionStringForDevelopment"].ConnectionString;
      //...
      application.Setup();
      //...
   }
}

Note

XAF removes the password from the XafApplication.ConnectionString property value for security reasons (to avoid exposure of sensitive information in logs, errors, and so on). You can access an unmodified connection string in the application configuration file. To do this, use the following API:

The following code snippets (auto-collected from DevExpress Examples) contain references to the ConnectionString property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also