LocalDBGetVersionInfo Function

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

Syntax

HRESULT LocalDBGetVersionInfo(
           PCWSTR wszVersionName,
           PLocalDBVersionInfo pVersionInfo,
           DWORD dwVersionInfoSize
);

Parameters

  • 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.

Returns

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

Remarks

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