I don't think you need ";" appended to the query string. I think it is added automatically.
Remove it and see if there's any difference.
I don't think you need ";" appended to the query string. I think it is added automatically.
Remove it and see if there's any difference.
Same result. And in both cases, I also get following warning in debugging process:Qt Code:
To copy to clipboard, switch view to plain text mode
Qt 5.3 Opensource & Creator 3.1.2
Everything is OK with the query, so the problem must be somewhere else. Double check you database connection... What happens if you pass the database as the second parameter to QSqlQuery.
MarkoSan (15th December 2007)
God damn, upon seinding paramaters to database, as 3rd paramater I've sent hostname instead of database name and normally, database was not activated. Marcel, thanks!!!!
But on the other hand, I have one more question. I have another function that retreives data from another table and it has been working perfectly before I've corrected this glitch with database paramaters. How is that possible?
Qt 5.3 Opensource & Creator 3.1.2
I don't know... Magic?
Maybe that database was the default schema for the user you connected with...
I will dig into this, it'a possible nasty bug, and let me report what I've discovered.
Qt 5.3 Opensource & Creator 3.1.2
This actually means that there is no error.
You don't invoke QSqlQuery::next() before value().
Also better use bindValue() to avoid SQL injection:
Qt Code:
QSqlQuery q; q.prepare( "SELECT * FROM `eros`.`merchandize` WHERE PicPath= :path" ); q.bindValue( ":path", strPicPath ); if( q.exec() ) { while( q.next() ) { // ... } } else { // error }To copy to clipboard, switch view to plain text mode
I have another big problem with QSqlQuery.
I'm binding values using bindValue() function. Inside exec() function driver()->formatValue() function is called for each binded value, so each '\' becames '\\'.
Is theer any way to avoid such behaviour?
(I have standart_conforming_strings = on in my postgres.conf so I don't need escaping '\' characters)
Hi,
Try to use this style
GetQry = ( char *) malloc ( ( 50 * sizeof ( char ) ) + 1 );
strcpy(GetQry, "select * from TableList where id > ");
TmpQry = ( char * ) realloc ( GetQry, sizeof( char ) * ( strlen(GetQry ) + strlen(TID) + 1 ) );
GetQry = TmpQry;
strcat(GetQry, TID);
and execute that string GetQry
![]()
Bookmarks