Hello,
I'm getting an error when trying to read an empty field in my database.
The problem apprear when reading the filed 9 and 10. But not with the fields 5 and 6. I copied the columns 5 and 6 to create columns 9 and 10. I changed the title of these columns of course.
All fields of these column are empty when executing my code. I should get an empty string as field 5 and 6, but when arriving to the filed 9 :
DBGetColChar (iHstmt, 9, &tcCode, ""); //Column 9
I get this error message :
NON-FATAL RUN-TIME ERROR: "DB.c", line 2655, col 9, thread id 0x00001F40: Function DBGetColChar: (return value == -2 [0xfffffffe]). The field/column contains null.
Here is my code :
.... iHstmt = DBActivateSQL (tiConnectionHandle[iConnectionBase], tcMessage); l_NumberOfRecords = DBNumberOfRecords(iHstmt); for(int recLoop = 0; recLoop < l_NumberOfRecords; recLoop++) { if( DBFetchNext (iHstmt) != DB_SUCCESS) break; ..............
// Get field 5 DBGetColChar (iHstmt, 5, &tcCode, ""); //Column 5 l_s_Alias.name = (char*) malloc(strlen(tcCode)+1); strcpy(l_s_Alias.name,tcCode); DBFree(tcCode); // Get field 6 DBGetColChar (iHstmt, 6, &tcCode, ""); //Column 6 l_s_Alias.name = (char*) malloc(strlen(tcCode)+1); strcpy(l_s_Alias.name,tcCode); DBFree(tcCode); // Get field 9 DBGetColChar (iHstmt, 9, &tcCode, ""); //Column 9 l_s_Alias.name = (char*) malloc(strlen(tcCode)+1); strcpy(l_s_Alias.name,tcCode); DBFree(tcCode); // Get field 10 DBGetColChar (iHstmt, 10, &tcCode, ""); //Column 10 l_s_Alias.name = (char*) malloc(strlen(tcCode)+1); strcpy(l_s_Alias.name,tcCode); DBFree(tcCode); } DBDeactivateSQL(iHstmt); ...
I checked the Default value of all fields in my Access DB, it's an empty string : ""
Any idea to solve this problem please ?
Regards,
Blue