Inserting hexadecimal in 1 row into MYSQL
Posted by: jason chan
Date: February 16, 2012 07:26PM

Hi all, I'm currently doing my final year project and im stuck on the following section.

Whenever i read from the RFID reader, its a 96 bit hexa value. However when i try to insert that value into MYSQL it appears to be in 12 different rows instead of in 1 row. For example, if the hexa value was 0A 60 00 00 00 00 00 00 00 00 00 01, Whenever use the insert function below, it appears as 12 different entries.(0A) would be in the first row, (60) would be in the second row and so on.

Can someone please help me solve the problem. Thanks.

the codes are as follow:

void CT1121Dlg::DisplayTagData(int cnt,int tag_len,int start_index)
{

MYSQL *pConnection;
MYSQL_RES *pResult=NULL;
MYSQL_ROW Row;
char Query[256];
int a;
int z = 25;
int fields;
pConnection = mysql_init(NULL);
mysql_real_connect(pConnection,"localhost","root","january123","test",0,NULL,0);

CString s,s0;
int i,j;
unsigned char t;
for(i = 0; i < cnt; i++)
{
s.Format("NO.%d: ",start_index+i+1);

for(j = 0; j < tag_len; j++)
{
t = IdBuf.Ids[j];
if(t < 0x10)
{
s0.Format("0%X ",t);

sprintf(Query, "insert into t(d) values ((%X))",t);
if ( mysql_query(pConnection,Query) == 0 )
{pResult = mysql_store_result( pConnection );
if ( pResult != NULL )
{
fields = mysql_num_rows( pResult );
printf( "Retrieved %u rows\n", fields );}
else
printf( "Query failed\n" );
}
}
else
s0.Format("%X ",t);

s += s0;
//printf("%s",t);

}


AddOprationInfo(s);
}
}

Options: ReplyQuote


Subject
Views
Written By
Posted
Inserting hexadecimal in 1 row into MYSQL
1161
February 16, 2012 07:26PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.