Delen via


LocalDBGetVersionInfo function

Applies to:SQL Server

Retourneert informatie voor de opgegeven SQL Server Express LocalDB-versie, zoals of deze bestaat en het volledige LocalDB-versienummer (inclusief build- en releasenummers).

De informatie wordt geretourneerd in de vorm van een struct benoemde, LocalDBVersionInfodie de volgende definitie heeft.

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:msoledbsql.h

Syntax

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

Arguments

wszVersionName

[Invoer] De naam van de LocalDB-versie.

pVersionInfo

[Uitvoer] De buffer voor het opslaan van de informatie over de LocalDB-versie.

dwVersionInfoSize

[Input] Holds the size of the VersionInfo buffer.

Returns

S_OK: De functie is geslaagd.

Error Description
LOCALDB_ERROR_NOT_INSTALLED SQL Server Express LocalDB is niet geïnstalleerd op de computer.
LOCALDB_ERROR_INVALID_PARAMETER Een of meer opgegeven invoerparameters zijn ongeldig.
LOCALDB_ERROR_UNKNOWN_VERSION De opgegeven LocalDB-versie bestaat niet.
LOCALDB_ERROR_INTERNAL_ERROR Er is een onverwachte fout opgetreden. Zie het gebeurtenislogboek voor meer informatie.

Details

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

If the struct size argument (lpVersionInfoSize) matches the size of a known version of the LocalDBVersionInfostruct, that version of the struct is returned. Anders wordt LOCALDB_ERROR_INVALID_PARAMETER geretourneerd.

Een typisch voorbeeld van LocalDBGetVersionInfo API-gebruik ziet er als volgt uit:

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

Remarks

Zie sql Server Express LocalDB-referentie voor een codevoorbeeld dat gebruikmaakt van de LocalDB-API van LocalDB.