Greetings, I'm sending this query to a third party program database using an ODBC driver

Qt Code:
  1. "SELECT table FROM Column WHERE DESCRIPCION = 'SOMETHING'"
To copy to clipboard, switch view to plain text mode 

my funtion should return a Stringlist with the values of column "o" where the value of column "k" match "pointer"

Let's say, for example that my table is like
Qt Code:
  1. code name lastname description
To copy to clipboard, switch view to plain text mode 

if i set o="0" it return the codes fine, but any value diferent that "0" return the error "QODBCResult::data: column # out of range".

This is the same funtion that I use for a Postgres database but for some reason it doesn't work with the ODBC driver

Qt Code:
  1. QStringList conecta2::leedb(QString table, int k, int o, QString pointer)
  2. {
  3. conectdbisam();
  4. QString line;
  5. QString line2;
  6. QStringList lista;
  7. int h;
  8. h=0;
  9. if(db.open())
  10. {
  11. QSqlQuery qry;
  12. if(qry.exec("SELECT * FROM "+table))
  13. {
  14. QSqlRecord rec = qry.record();
  15. columna = rec.fieldName(k);
  16. }
  17. if(qry.exec("SELECT "+columna+" FROM "+table+" WHERE "+columna+" = '"+pointer+"'"))
  18. {
  19. while(qry.next())
  20. {
  21. line2 =qry.value(o).toString().simplified();
  22. lista.append(line2);
  23. h++;
  24. if (h==500)
  25. break;
  26. }
  27. }
  28. else
  29. {
  30. qDebug() << "Error =" << db.lastError().text();
  31. }
  32. qry.clear();
  33. }
  34. else
  35. {
  36. qDebug() << "Error =" << db.lastError().text();
  37. }
  38. return QStringList(lista);
  39. }
To copy to clipboard, switch view to plain text mode 

Does anyone see the problem with this code, or maybe a work around?

Thank in advance.