Home My program reads 0 from the database even though there is a 1
Reply: 0

My program reads 0 from the database even though there is a 1

user888
1#
user888 Published in April 24, 2018, 8:22 am

I don't understand whats wrong with the code, I have read a lot of times but I can't find the error

pstmt = con->prepareStatement("SELECT (?) FROM votos WHERE id = (?)");
pstmt->setString(1, eleccion);
pstmt->setInt(2, p->getId());
res = pstmt->executeQuery();
while(res->next())
{
    p->setVoto(res->getInt(1));
}

When the eleccion and id variables are Provincial and 1 respectively the getInt(1) function should return 1, but it returns 0.

The command (in the mysql command line):

SELECT Provincial from Votos WHERE id=1

Returns a table with one row and one column with the value 1

Side notes:

Spelling was checked

The getId() function works correctly

The compiler doesn't give any error

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.308636 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO