Share via


LocalDBStartInstance Function

Starts the specified SQL Server Express LocalDB instance.

Header file: sqlncli.h

Syntax

HRESULT LocalDBStartInstance(
           PCWSTR pInstanceName,
           DWORD dwFlags, 
           LPWSTR wszSqlConnection, 
           LPDWORD lpcchSqlConnection 
);

Parameters

  • pInstanceName
    [Input] The name of the LocalDB instance to start.

  • dwFlags
    [Input] Reserved for future use. Currently should be set to 0.

  • wszSqlConnection
    [Output] The buffer to store the connection string to the LocalDB instance.

  • lpcchSqlConnection
    [Input/Output] On input contains the size of the wszSqlConnection buffer in characters, including any trailing nulls. On output, if the given buffer size is too small, contains the required buffer size in characters, including any trailing nulls.

Returns

Details

Both the connection buffer argument (wszSqlConnection) and the connection buffer size argument (lpcchSqlConnection) are optional. The following table shows options for using these arguments and their results.

Buffer

Buffer size

Rationale

Action

NULL

NULL

User wants to start the instance and doesn’t need a pipe name.

Starts an instance (no pipe return and no required buffer size return).

NULL

Present

User asks for the output buffer size. (In the next call the user will probably ask for an actual start.)

Returns a required buffer size (no start and no pipe return). Result is S_OK.

Present

NULL

Not allowed; incorrect input.

Returned result is LOCALDB_ERROR_INVALID_PARAMETER.

Present

Present

User wants to start the instance and needs the pipe name to connect to it after it is started.

Checks the buffer size, starts the instance, and returns the pipe name in the buffer. The buffer size argument returns the length of the “server=” string, not including terminating nulls.

For a code sample that uses LocalDB API, see SQL Server Express LocalDB Reference.

See Also

Concepts

SQL Server Express LocalDB Header and Version Information