Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Solved]Can't save to changes to mysql.



  • I can load the table fine. But when I change a value and sort a column or refresh the table the chance is not applied.

    Main (no problems here)
    @
    db = QSqlDatabase::addDatabase("QMYSQL");
    ..
    db.open();
    model=new QSqlTableModel(this);
    model->setTable("movieview");
    model->setEditStrategy(QSqlTableModel::OnManualSubmit);
    loadDB();@

    @void MainWindow::on_Connectsql_button_clicked()
    {
    model->submitAll(); // <- should write model back to database no?
    loadDB();
    }

    void MainWindow::loadDB(){
    QString debugg = model->lastError().text();
    qDebug() << debugg;
    qDebug() << QSqlDatabase::drivers();
    model->select();

    ui->tableView->setModel(model);
    
    for ( int i = 0; i <= 1; i++)
    {ui->tableView->hideColumn(i);}
    for ( int i = 3; i <= 25; i++)
    {ui->tableView->hideColumn(i);}
    for ( int i = 28; i <= 29; i++)
    {ui->tableView->hideColumn(i);}
    

    }@

    Debug output on click button :

    bq. " "
    ("QSQLITE", "QMYSQL", "QMYSQL3", "QODBC", "QODBC3", "QPSQL", "QPSQL7")
    "Using unsupported buffer type: 380399704 (parameter: 3) QMYSQL3: Unable to bind value"

    The buffer error occurs when i changed a cell and clicked the button.

    Not sure why it shows qmysql3.
    Any guidance in this would be appreciated.

    No clue where the libmysql.dll from 2006 came from. replaced by the one from the mysql lib folder.
    Works now.


Log in to reply