Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
Applies to:SQL Server
Restituisce informazioni per l'istanza di SQL Server Express LocalDB specificata, ad esempio se esiste, la versione di LocalDB usata, se è in esecuzione e così via.
Le informazioni vengono restituite in un struct oggetto denominato LocalDBInstanceInfo, che ha la definizione seguente.
typedef struct _LocalDBInstanceInfo
{
// Contains the size of the LocalDBInstanceInfo struct
DWORD cbLocalDBInstanceInfoSize;
// Holds the instance name
TLocalDBInstanceNamewszInstanceName;
// TRUE if the instance files exist on disk, FALSE otherwise
BOOL bExists;
// TRUE if the instance configuration registry is corrupted, FALSE otherwise
BOOLbConfigurationCorrupted;
// TRUE if the instance is running at the moment, FALSE otherwise
BOOL bIsRunning;
// Holds the LocalDB version for the instance in the format: major.minor.build.revision
DWORD dwMajor;
DWORD dwMinor;
DWORD dwBuild;
DWORD dwRevision;
// Holds the date and time when the instance was started for the last time
FILETIME ftLastStartUTC;
// Holds the name of the TDS named pipe to connect to the instance
WCHARwszConnection;
// TRUE if the instance is shared, FALSE otherwise
BOOLbIsShared;
// Holds the shared name for the instance (if the instance is shared)
TLocalDBInstanceNamewszSharedInstanceName;
// Holds the SID of the instance owner (if the instance is shared)
WCHARwszOwnerSID;
// TRUE if the instance is Automatic, FALSE otherwise
BOOLbIsAutomatic;
} LocalDBInstanceInfo;
Header file:msoledbsql.h
Syntax
HRESULT LocalDBGetInstanceInfo(
PCWSTR wszInstanceName ,
PLocalDBInstanceInfo pInstanceInfo ,
DWORD dwInstanceInfoSize
);
Arguments
wszInstanceName
[Input] Nome dell'istanza.
pInstanceInfo
[Output] Buffer per archiviare le informazioni sull'istanza del database locale.
dwInstanceInfoSize
[Input] Holds the size of the InstanceInfo 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_INVALID_INSTANCE_NAME | Nome dell'stanza specificata non valido. |
| LOCALDB_ERROR_UNKNOWN_INSTANCE | L'istanza non esiste. |
| LOCALDB_ERROR_INSTANCE_FOLDER_PATH_TOO_LONG | Il percorso in cui l'istanza deve essere archiviata è più lunga di MAX_PATH. |
| LOCALDB_ERROR_CANNOT_ACCESS_INSTANCE_FOLDER | Non è possibile accedere a una cartella di istanza. |
| LOCALDB_ERROR_CANNOT_ACCESS_INSTANCE_REGISTRY | Non è possibile accedere a un registro di istanze. |
| LOCALDB_ERROR_INSTANCE_CONFIGURATION_CORRUPT | Configurazione di un'istanza danneggiata. |
| LOCALDB_ERROR_INTERNAL_ERROR | Errore imprevisto. Per informazioni, vedere il registro eventi. |
Details
The rationale behind the introduction of the struct size argument (lpInstanceInfoSize) is to enable the API to return different versions of the LocalDBInstanceInfostruct, effectively enabling forward and backward compatibility.
If the struct size argument (lpInstanceInfoSize) matches the size of a known version of the LocalDBInstanceInfostruct, that version of the struct is returned. In caso contrario, viene restituito LOCALDB_ERROR_INVALID_PARAMETER.
Un esempio tipico di utilizzo dell'API LocalDBGetInstanceInfo è simile al seguente:
LocalDBInstanceInfo ii;
LocalDBInstanceInfo(L"Test", &ii, sizeof(LocalDBInstanceInfo));
Per un esempio di codice che usa l'API LocalDB, vedere Informazioni di riferimento su SQL Server Express LocalDB.