| title | LocalDBFormatMessage Function |
|---|---|
| description | LocalDBFormatMessage returns the localized textual description for the specified SQL Server Express LocalDB error. |
| author | markingmyname |
| ms.author | maghan |
| ms.reviewer | randolphwest |
| ms.date | 07/14/2025 |
| ms.service | sql |
| ms.topic | reference |
| apilocation | sqluserinstance.dll |
| apiname | LocalDBFormatMessage |
| apitype | DLLExport |
[!INCLUDE SQL Server]
Returns the localized textual description for the specified SQL Server Express LocalDB error.
Header file: msoledbsql.h
HRESULT LocalDBFormatMessage(
HRESULT hrLocalDB ,
DWORD dwFlags ,
DWORD dwLanguageId ,
LPWSTR wszMessage ,
LPDWORD lpcchMessage
);[Input] The LocalDB error code.
[Input] The flags specifying the behavior of this function.
Available flags:
If the input buffer is too short, the error message is truncated to fit the buffer.
[Input] The language desired (LANGID) or 0, in which case the Win32 FormatMessage language order is used.
[Output] The buffer to store the LocalDB error message.
[Input/Output] On input, this option contains the size of the wszMessage buffer in characters. On output, if the given buffer size is too small, contains the buffer size required in characters, including any trailing nulls. If the function succeeds, this option contains the number of characters in the message, excluding any trailing nulls.
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_UNKNOWN_ERROR_CODE | The requested message doesn't exist. |
| LOCALDB_ERROR_UNKNOWN_LANGUAGE_ID | The message isn't available in the requested language. |
| LOCALDB_ERROR_INSUFFICIENT_BUFFER | The input buffer wszMessage is too short, and truncation isn't requested. |
| 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.