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
      TLocalDBVersionwszVersion;

      // 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
);

wszVersionName

[Input] The LocalDB version name.

pVersionInfo

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

dwVersionInfoSize

[Input] Holds the size of the VersionInfo buffer.

S_OK

The function succeeded.

LOCALDB_ERROR_NOT_INSTALLED

SQL Server Express LocalDB is not installed on the computer.

LOCALDB_ERROR_INVALID_PARAMETER

One or more specified input parameters are invalid.

LOCALDB_ERROR_UNKNOWN_VERSION

The specified LocalDB version does not exist.

LOCALDB_ERROR_INTERNAL_ERROR

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

ADD
Show:
© 2015 Microsoft