Need help comparing db field values in c++
I am trying to compare 2 different text fields from ms sql db, and want to set a condition based on wether or not the 2 text fields contain the same text or not. I believe that c++ is setup to use a character array to hold the db fields, and I have tried to use strcmp to compare the values, but it seems like I am only getting comparisions on whether or not the db fields are NULL or not, and that it is not actually comparing the db field values.
Basically all I need to do is:
if field1 value is not equal to field2 value, then outofrange=1.
I used != to specify inequality, but like I said before, it's almost like it's not looking at the value of the fields, only at whether or not the fields are NULL.
Am I doing something wrong?
I am pretty new to c++, apologies for my ignorence.
Thanks in advance for any help!
What happens when you capture the field values in variables and compare them at the variable level?
Thanks for thr reply.
I have compared at the variable level as well, but received the exact same results.
Have you tried issue the comparison at the database level?
Select if(col1 = col2, x, y) as result
What datatype are the variables you compared?
sql datatype is varchar.
I can not do compare at DB level because I am building upon existing code that performs other db field functions at C level already.
show us the code you used to compare the values
Here is the code specific to the compare:
if (strcmp(sc[i].birace1, fam.accept_birace1)) outofrange=1;