You are casting ClientID to char* causing the function to assume its a null terinated char array, which it is not.
from cplusplus.com :
string& append ( const char * s ); Appends a copy of the string formed
by the null-terminated character sequence (C string) pointed by s. The
length of this character sequence is determined by the first ocurrence
of a null character (as determined by traits.length(s)).
I have a feeling that your ClientID is not of a string type (zero-terminated char* or std::string) but some integral type (e.g. int) so you need to convert number to the string first:
std::stringstream ss;
ss << ClientID;
query.append(ss.str());
But you can use operator+ as well (instead of append):