Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

LocalDBGetVersionInfo Function

Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).

Returns information for the specified SQL Server Express LocalDB version, such as whether it exists and the full LocalDB version number (including build and release numbers).

The information is returned in the form of a struct named LocalDBVersionInfo, which has the following definition.

typedef struct _LocalDBVersionInfo
      // Contains the size of the LocalDBVersionInfo struct
      DWORD  cbLocalDBVersionInfoSize;

      // Holds the version name

      // TRUE if the instance files exist on disk, FALSE otherwise
      BOOL   bExists;

      // Holds the LocalDB version for the instance in the format: major.minor.build.revision
      DWORD  dwMajor;
      DWORD  dwMinor;
      DWORD  dwBuild;
      DWORD  dwRevision;
} LocalDBVersionInfo;

Header file: sqlncli.h

HRESULT LocalDBGetVersionInfo(
           PCWSTR wszVersionName,
           PLocalDBVersionInfo pVersionInfo,
           DWORD dwVersionInfoSize


[Input] The LocalDB version name.


[Output] The buffer to store the information about the LocalDB version.


[Input] Holds the size of the VersionInfo buffer.


The function succeeded.


SQL Server Express LocalDB is not installed on the computer.


One or more specified input parameters are invalid.


The specified LocalDB version does not exist.


An unexpected error occurred. See the event log for details.

The rationale behind the introduction of the struct size argument (lpVersionInfoSize) is to enable the API to return different versions of the LocalDBVersionInfo struct, effectively enabling forward and backward compatibility.

If the struct size argument (lpVersionInfoSize) matches the size of a known version of the LocalDBVersionInfo struct, that version of the struct is returned. Otherwise, LOCALDB_ERROR_INVALID_PARAMETER is returned.

A typical example of LocalDBGetVersionInfo API usage looks like this:

LocalDBVersionInfo vi;
LocalDBVersionInfo(L”11.0”, &vi, sizeof(LocalDBVersionInfo));

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

Community Additions

© 2015 Microsoft