I'm new here. These days I have been working with the MySQL Connector/ Arduino library. So, my problem is how can i retrieve a rows data so as to enable an output. I have written some code, which was going pretty good, but here is where my problem is introduced:
void query_analysis_states () {
row_values *row = NULL;
column_names *columns = NULL;
SQL_SETUP.cmd_query(QUERY_STATE_SQL);
columns = SQL_SETUP.get_columns();
do {
row = SQL_SETUP.get_next_row();
if (row != NULL) {
for (int f = 0; f < columns->num_fields; f++) {
state_Array[f] = atoi(row->values[f]);
}
}
} while (row != NULL);
}
So the problem is that if I put a serial.print inside the for loop, I get the correct states which I have requested. If, I put it outside, I get them all wrong, like they are gone missing, for example I get states 1, 0, 1 and then 0, 0, 0 or something else. That means that the array also which plays the role of capturing the data from the row doesn't work when I call the method. Can anyone please help me? If you want me to post the rest of the code, please tell me. Thank you in advance.