rc 返回 -1 但在调用 SQLGetDiagRec 后我无法获得任何错误消息和状态
SQLRETURN rc;
SQLHENV henv1 = NULL;
SQLHDBC hdbc1= NULL;
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv1);
SQLSetEnvAttr(henv1,SQL_ATTR_ODBC_VERSION,(void*)SQL_OV_ODBC3,0);
rc =SQLAllocHandle(SQL_HANDLE_DBC, henv1, &hdbc1);
char szDSN[256] = "Driver={Microsoft Access Driver (*.mdb, *.accdb)};DSN=data;DBQ=D:\\data\\data.accdb;";
char out[256];
int iConnStrLength2Ptr;
rc = SQLDriverConnect(hdbc1, NULL, (SQLWCHAR*)&szDSN, SQL_NTS, (SQLWCHAR*)&out,255, (SQLSMALLINT*)&iConnStrLength2Ptr, SQL_DRIVER_NOPROMPT);
SQLWCHAR SQLState[256];
SQLINTEGER NativeErrorPtr;
SQLWCHAR MessageText[256];
SQLSMALLINT TextLengthPtr = 255;
SQLGetDiagRec(SQL_HANDLE_ENV,henv1,1,(SQLWCHAR*)SQLState,&NativeErrorPtr,(SQLWCHAR*)MessageText,255,&TextLengthPtr);