public DB2ErrorCollection(short sqlHandleType, IntPtr sqlHandle) { StringBuilder sqlState = new StringBuilder(10); StringBuilder errorMessage = new StringBuilder(1025); int sqlReturn; short recNum = 1; do { int nativeError; short errorMessageLength; sqlReturn = DB2CLIWrapper.SQLGetDiagRec(sqlHandleType, sqlHandle, recNum++, sqlState, out nativeError, errorMessage, errorMessage.Capacity - 1, out errorMessageLength); if (sqlReturn == 0) { Add(new DB2Error(errorMessage.ToString(), sqlState.ToString(), nativeError)); } }while (sqlReturn == 0); }