OK, did not get much on my question so I have been trying to come up with some better error checking and my question has altered a bit....
I am trying to follow some example code off the web where I can tie a string variable for assigning the return errors from my testing of the SQLExecute, can some one help me understand how to tie *inMessage into my return code checks and balance statmenet of :
Code:
else if (retcode == SQL_ERROR || retcode == SQL_NO_DATA || retcode==SQL_INVALID_HANDLE)
{
SQLCHAR SqlState[6];
SQLINTEGER NativeError;
SQLCHAR ErrMsg[SQL_MAX_MESSAGE_LENGTH];
int i = 1;
char message[512];
strcpy (message, "");
if (inMessage) {
strcpy(message, inMessage);
strcat(message, " — ");
}
sprintf(message, "%sError in SQLConnect(): %d.",
message, retcode);
fout<<message<<endl;
while(SQLGetDiagRec(SQL_HANDLE_DBC, hDbConn, i,
SqlState, &NativeError,
ErrMsg, sizeof(ErrMsg), NULL)
!= SQL_NO_DATA)
{
sprintf(message,"Diag: %d, SQLSTATE: %s NativeError: %d ErrMsg: %s",
i++, SqlState, NativeError, ErrMsg);
fout<<message<<endl;
}
}
I understand the principles of this sample code, which the much better coder, the original author, uses a function call and passes retcode and *inMessage to the function and then uses that in the output. I understand the retcode, I think, but I never saw where const char *inMessage was passed into the "if" statement to grab text based return error messaging. Which I am hoping will point out my SQLExecute failure..... Sorry for the lengthy question, the frustration is setting in more and I am finding my online research a bit over my head. Thanks-