Results 1 to 9 of 9

Thread: [Qt4.5] MySql strange beheavior

  1. #1
    Join Date
    Aug 2006
    Location
    Some where in Argentina
    Posts
    23
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Question [Qt4.5] MySql strange beheavior

    My new server has been installed and im using it to test my program with it...

    But muy problem is that the tables that shows the contents gets the double of the amount of real records in the database, and beyond of the record 99 nothing is showed on the view...
    Same code on SQLite works perfect...
    Using it on windows and linux, with a mysql server version 5...

    When I try to delete some of the "empty" records, tells me that the row is not fetchable...

    Some one has experienced the same problem?

  2. #2
    Join Date
    Mar 2009
    Posts
    25
    Thanked 2 Times in 2 Posts

    Default Re: [Qt4.5] MySql strange beheavior

    What will the result be if you use not Qt but the MySQL shell to execute the queries?

  3. #3
    Join Date
    Aug 2006
    Location
    Some where in Argentina
    Posts
    23
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [Qt4.5] MySql strange beheavior

    if i get exec the query on sheell all the data gets showed...
    I've try using
    Qt Code:
    1. while( modelo->canFetchMore() )
    2. { modelo->fetchMore(); }
    To copy to clipboard, switch view to plain text mode 
    but the same behavior...
    The tableview use a QSqlRelationalTableModel, both tables has correct data, no missing foregin keys...
    Last edited by tranfuga25s; 2nd April 2009 at 18:32.

  4. #4
    Join Date
    Mar 2009
    Posts
    25
    Thanked 2 Times in 2 Posts

    Default Re: [Qt4.5] MySql strange beheavior

    Now that query in shell is ok, db is not corrected

    Try to locate where the problem arises.
    Try to write a loop with rowCount() and record(), and output the table content with qDebug(), so that we know if the query result itself is incorrect or it is the view that is not displaying correctly.

  5. #5
    Join Date
    Aug 2006
    Location
    Some where in Argentina
    Posts
    23
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [Qt4.5] MySql strange beheavior

    whell seems that the query is the problem, got the same problem with the loops:
    Qt Code:
    1. for( int i=0; i<modelo->rowCount(); i++ )
    2. {
    3. for( int j=0; j<modelo->record().count(); j++ )
    4. {
    5. qDebug( qPrintable( modelo->record(i).value( j ).toString() ) );
    6. }
    7. qDebug( "--" );
    8. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. Debug: --
    2. Debug: 99
    3. Debug: Alimentos Balanceados
    4. Debug: mijo
    5. Debug: 3.000
    6. Debug:
    7. Debug:
    8. Debug: --
    9. Debug:
    10. Debug:
    11. Debug:
    12. Debug:
    13. Debug:
    14. Debug:
    15. Debug: --
    To copy to clipboard, switch view to plain text mode 
    The model is contructed like this

    Qt Code:
    1. setTable( "producto" );
    2. setHeaderData( 0, Qt::Horizontal, "#ID" );
    3. setHeaderData( 1, Qt::Horizontal, "Categoria" );
    4. setRelation( 1, QSqlRelation( "categoria", "id", "nombre" ) );
    5. setHeaderData( 2, Qt::Horizontal, "Nombre" );
    6. setHeaderData( 3, Qt::Horizontal, "Precio de Venta" );
    7. setHeaderData( 4, Qt::Horizontal, "Descripcion" );
    8. setHeaderData( 5, Qt::Horizontal, "Marca" );
    To copy to clipboard, switch view to plain text mode 
    and the table is

    Qt Code:
    1. CREATE TABLE `producto` (
    2. `id` bigint(1) NOT NULL auto_increment,
    3. `id_categoria` int(1) NOT NULL,
    4. `nombre` tinytext NOT NULL,
    5. `precio_venta` decimal(6,3) NOT NULL,
    6. `descripcion` text,
    7. `marca` tinytext,
    8. PRIMARY KEY (`id`)
    9. ) ENGINE=MyISAM AUTO_INCREMENT=256 DEFAULT CHARSET=latin1
    To copy to clipboard, switch view to plain text mode 
    the modelo->query().executedQuery() returns
    Qt Code:
    1. SELECT `producto`.`id`,`relTblAl_1`.`nombre` AS categoria_nombre,`producto`.`nombre`,`producto`.`precio_venta`,`producto`.`descripcion`,`producto`.`marca` FROM `producto`,`categoria` `relTblAl_1` WHERE (`producto`.`id_categoria`=`relTblAl_1`.`id`)
    To copy to clipboard, switch view to plain text mode 
    The query works ok on mysql shell...
    qt bug?
    Any advice?
    Last edited by tranfuga25s; 2nd April 2009 at 20:05.

  6. #6
    Join Date
    Aug 2006
    Location
    Some where in Argentina
    Posts
    23
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [Qt4.5] MySql strange beheavior

    The same appens in another query where the result is bigger than 100 records... Code problem? server problem? any ideas?

  7. #7
    Join Date
    Aug 2006
    Location
    Some where in Argentina
    Posts
    23
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [Qt4.5] MySql strange beheavior [MySql 5]

    Can be the problem the version of the mysql server that I'm using? The version is 5.0.17
    Can it be that the mysql driver that I have for qt is only compatible with servers < 5??

  8. #8
    Join Date
    Aug 2006
    Location
    Some where in Argentina
    Posts
    23
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Question Re: [Qt4.5] MySql strange beheavior

    nop, not a problem with the mysql drivers... I've compiled it from source and there is no change...
    Any idea if the names of the fields in the database can this to appen??
    I'm running out of ideas...

  9. #9
    Join Date
    Aug 2006
    Location
    Some where in Argentina
    Posts
    23
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [Qt4.5] MySql strange beheavior

    Same problem with sqlbrowser example from qt sources.... on all tables that have more than 99 records, the others ones are empty

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.