Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Applies to:SQL Server
Mengembalikan informasi untuk instans SQL Server Express LocalDB yang ditentukan, seperti apakah ada, versi LocalDB yang digunakannya, apakah itu berjalan, dan sebagainya.
Informasi dikembalikan dalam bernama structLocalDBInstanceInfo, yang memiliki definisi berikut.
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] Nama instans.
pInstanceInfo
[Output] Buffer untuk menyimpan informasi tentang instans LocalDB.
dwInstanceInfoSize
[Input] Holds the size of the InstanceInfo buffer.
Returns
S_OK: Fungsi berhasil.
| Error | Description |
|---|---|
| LOCALDB_ERROR_NOT_INSTALLED | SQL Server Express LocalDB tidak diinstal di komputer. |
| LOCALDB_ERROR_INVALID_PARAMETER | Satu atau beberapa parameter input yang ditentukan tidak valid. |
| LOCALDB_ERROR_INVALID_INSTANCE_NAME | Nama instans yang ditentukan tidak valid. |
| LOCALDB_ERROR_UNKNOWN_INSTANCE | Instans tidak ada. |
| LOCALDB_ERROR_INSTANCE_FOLDER_PATH_TOO_LONG | Jalur tempat instans harus disimpan lebih panjang dari MAX_PATH. |
| LOCALDB_ERROR_CANNOT_ACCESS_INSTANCE_FOLDER | Folder instans tidak dapat diakses. |
| LOCALDB_ERROR_CANNOT_ACCESS_INSTANCE_REGISTRY | Registri instans tidak dapat diakses. |
| LOCALDB_ERROR_INSTANCE_CONFIGURATION_CORRUPT | Konfigurasi instans rusak. |
| LOCALDB_ERROR_INTERNAL_ERROR | Terjadi kesalahan tidak terduga. Lihat log peristiwa untuk detailnya. |
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. Jika tidak, LOCALDB_ERROR_INVALID_PARAMETER dikembalikan.
Contoh LocalDBGetInstanceInfo umum penggunaan API terlihat seperti ini:
LocalDBInstanceInfo ii;
LocalDBInstanceInfo(L"Test", &ii, sizeof(LocalDBInstanceInfo));
Untuk sampel kode yang menggunakan API LocalDB, lihat referensi SQL Server Express LocalDB.