Freigeben über


LocalDBGetVersionInfo function

Applies to:SQL Server

Gibt Informationen zur angegebenen SQL Server Express-LocalDB-Version zurück, z. B., ob sie vorhanden ist sowie die vollständige LocalDB-Versionsnummer (inklusive Build- und Releasenummer).

Die Informationen werden in Form eines struct benannten LocalDBVersionInfoNamens zurückgegeben, der die folgende Definition aufweist.

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

[Eingabe] Der Name der LocalDB-Version.

pVersionInfo

[Ausgabe] Der Puffer zum Speichern der Informationen zur LocalDB-Version.

dwVersionInfoSize

[Input] Holds the size of the VersionInfo buffer.

Returns

S_OK: Die Funktion war erfolgreich.

Error Description
LOCALDB_ERROR_NOT_INSTALLED SQL Server Express LocalDB ist nicht auf dem Computer installiert.
LOCALDB_ERROR_INVALID_PARAMETER Mindestens ein angegebener Eingabeparameter ist ungültig.
LOCALDB_ERROR_UNKNOWN_VERSION Die angegebene LocalDB-Version ist nicht vorhanden.
LOCALDB_ERROR_INTERNAL_ERROR Ein unerwarteter Fehler ist aufgetreten. Weitere Informationen finden Sie im Ereignisprotokoll.

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. Andernfalls wird LOCALDB_ERROR_INVALID_PARAMETER zurückgegeben.

Ein typisches Beispiel für die LocalDBGetVersionInfo API-Verwendung sieht wie folgt aus:

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

Remarks

Ein Codebeispiel, das die LocalDB-API verwendet, finden Sie unter SQL Server Express LocalDB-Referenz.