.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

MSSqlConnectionProvider.GetConnectionStringWithAttach(String, String, String, String, Boolean) Method

Returns a connection string to connect to a MS SQL Server database by attaching a specified .mdf database file to a specific server using specified login credentials.

Namespace: DevExpress.Xpo.DB

Assembly: DevExpress.Xpo.v20.1.dll

Declaration

public static string GetConnectionStringWithAttach(
    string server,
    string userId,
    string password,
    string attachDbFilename,
    bool userInstance
)
Public Shared Function GetConnectionStringWithAttach(
    server As String,
    userId As String,
    password As String,
    attachDbFilename As String,
    userInstance As Boolean
) As String

Parameters

Name Type Description
server String

A string that specifies the SQL server name.

userId String

A string that specifies a user name.

password String

A string that specifies the password. This is used to initialize the "Password" field of the connection string.

attachDbFilename String

A string specifying a .mdf database file to attach to the server. This value is used to initialize the "AttachDbFilename" field of the connection string.

userInstance Boolean

true to enable User Instances (required when attaching the attachDbFilename); otherwise, false (when the database specified by the attachDbFilename already exists on the server). This value is used to initialize the "User Instance" field of the connection string.

For more information about SQL Server Express and User Instances, read the SQL Server 2005 Express Edition User Instances MSDN article.

Returns

Type Description
String

A connection string.

Remarks

NOTE

This method is in effect only for SQL Server 2005 Express Edition databases.

The method adds the provided userid and password login credentials to the resulting connection string. To connect using Windows Integrated Security, call the other GetConnectionStringWithAttach overloaded method.

See Also