1

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.

  • 3
    I'm voting to close this question as off-topic because it is abandoned and the OP already solved it more than year ago – user31481 Oct 22 '17 at 14:12
1

Sorry for the inconvenience, problem solved! The problem was simple as I was getting both two columns except one!

void query_analysis_gates() {
  row_values *row = NULL;
  column_names *columns = NULL;
  SQL_SETUP.cmd_query(QUERY_GATE_SQL);
  columns = SQL_SETUP.get_columns();
  counter = 0;
  do {
    row = SQL_SETUP.get_next_row();
    if (row != NULL) {
      gate_Array[counter] = atoi(row->values[0]);
      counter++;
    }
  } while (row != NULL);
}

I provide this if anyone needs help with another method but it does the same function.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.