A breakpoint instruction (__debugbreak() statement or a similar call) was executed on SQLExecDirect CALL

419 Views Asked by At

I'm running a C++ visual studio 2022 console application and have a very simple SQL step the one randomly give me an error, the error are always in the same call SQLExecDirect() but happens around 1 in 100 times, I already try to catch the error and the exception but don't work, the same happened on debug or in release modes, if compile the Release .exe this error close the program when go in this error.

I try to change the SQLQuery_CHAR argument in many ways string, char, unsigned char, SQLCHAR but always happened the same.

If press F5 after the error all continue working fine inclusive the SQL call how crash make hers updates.

I need some way of catch this error to cud continue runing.

//OPTION A DON'T CATCH
SQLRETURN _SQLExecDirect(SQLCHAR* SQLQuery_CHAR)
{

    try
    {
        return SQLExecDirect(SQLStatementHandle, SQLQuery_CHAR, SQL_NTS);
    }
    catch (int e)
    {
        printf("In main handler\n");
    }
    return 0;
}

//OPTION B DON'T CATCH
SQLRETURN _SQLExecDirect(SQLCHAR* SQLQuery_CHAR)
{


    __try
    {
        return SQLExecDirect(SQLStatementHandle, SQLQuery_CHAR, SQL_NTS);
    }
    __except (EXCEPTION_EXECUTE_HANDLER)
    {
        printf("In main handler\n");
    }
    return 0;
}
0

There are 0 best solutions below