C++ ODBC を使用してローカル SQL Server に接続しています。
サーバーへの接続を試みたら; 接続が実際に成功したことを検証する方法はありますか?
これは、接続ハンドルを委任して接続を確立するコードのサンプルです。
//Allocate the pre-connection handles
this->sReturn = SQL_SUCCESS;
this->sReturn = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &this->eHandle);
this->sReturn = SQLSetEnvAttr(this->eHandle, SQL_ATTR_ODBC_VERSION, reinterpret_cast<void*>(SQL_OV_ODBC3_80), 4);
SQLAllocHandle(SQL_HANDLE_DBC, this->eHandle, &this->cHandle);
//Connect to the database
this->sReturn = SQLConnect(this->cHandle, reinterpret_cast<SQLWCHAR*>(serverName), SQL_NTS, NULL, 0, NULL, 0);