Condividi tramite


LocalDBGetVersionInfo function

Applies to:SQL Server

Vengono restituite le informazioni per la versione del database locale di SQL Server Express specificata, se esistente, e il numero completo della versione del database locale, ovvero con i numeri di compilazione e della versione inclusi.

Le informazioni vengono restituite sotto forma di , structLocalDBVersionInfoche ha la definizione seguente.

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

[Input] Nome della versione del database locale.

pVersionInfo

[Output] Buffer per archiviare le informazioni sulla versione del database locale.

dwVersionInfoSize

[Input] Holds the size of the VersionInfo buffer.

Returns

S_OK: la funzione ha avuto esito positivo.

Error Description
LOCALDB_ERROR_NOT_INSTALLED SQL Server Express LocalDB non è installato nel computer.
LOCALDB_ERROR_INVALID_PARAMETER Uno o più parametri di input specificati non validi.
LOCALDB_ERROR_UNKNOWN_VERSION La versione specificata di LocalDB non esiste.
LOCALDB_ERROR_INTERNAL_ERROR Errore imprevisto. Per informazioni, vedere il registro eventi.

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. In caso contrario, viene restituito LOCALDB_ERROR_INVALID_PARAMETER.

Un esempio tipico di utilizzo dell'API LocalDBGetVersionInfo è simile al seguente:

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

Remarks

Per un esempio di codice che usa l'API LocalDB, vedere Informazioni di riferimento su SQL Server Express LocalDB.