| title | LocalDBShareInstance Function |
|---|---|
| description | LocalDBShareInstance shares the specified SQL Server Express LocalDB instance with other users of the computer. |
| author | markingmyname |
| ms.author | maghan |
| ms.reviewer | randolphwest |
| ms.date | 07/14/2025 |
| ms.service | sql |
| ms.topic | reference |
| apilocation | sqluserinstance.dll |
| apiname | LocalDBShareInstance |
| apitype | DLLExport |
[!INCLUDE SQL Server]
Shares the specified SQL Server Express LocalDB instance with other users of the computer, using the specified shared name.
Header file: msoledbsql.h
HRESULT LocalDBShareInstance(
PSID pOwnerSID ,
PCWSTR pInstancePrivateName ,
PCWSTR pInstanceSharedName ,
DWORD dwFlags
);[Input] The SID of the instance owner.
[Input] The private name for the LocalDB instance to share.
[Input] The shared name for the LocalDB instance to share.
[Input] Reserved for future use. Currently should be set to 0.
S_OK: The function succeeded.
| Error | Description |
|---|---|
| LOCALDB_ERROR_NOT_INSTALLED | SQL Server Express LocalDB isn't installed on the computer. |
| LOCALDB_ERROR_INVALID_PARAMETER | One or more specified input parameters are invalid. |
| LOCALDB_ERROR_INVALID_INSTANCE_NAME | The specified instance name is invalid. |
| LOCALDB_ERROR_UNKNOWN_INSTANCE | The specified instance doesn't exist. |
| LOCALDB_ERROR_ADMIN_RIGHTS_REQUIRED | Administrator privileges are required in order to execute this operation. |
| LOCALDB_ERROR_SHARED_NAME_TAKEN | The specified shared name is already taken. |
| LOCALDB_ERROR_INSTANCE_ALREADY_SHARED | The specified instance is already shared. |
| LOCALDB_ERROR_INTERNAL_ERROR | An unexpected error occurred. See the event log for details. |
For a code sample that uses LocalDB API, see SQL Server Express LocalDB reference.