I want add text from textedit to database



  • @
    #include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    mydb=QSqlDatabase::addDatabase("QSQLITE");
    mydb.setDatabaseName("C:/program1.sqlite");
    
    if(!mydb.open())
        ui->label->setText("Failed");
    else
        ui->label->setText("Open");
    

    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::on_pushButton_clicked()
    {
    mydb.exec("INSERT INTO personabcd VALUES (null , ??????)");
    }
    @

    i have textedit where i can write something, i'm connected to database, now i want add what i write in textedit to database when i clicked button. What i must do?

    [Edited: Please use code tags "@@" - p3c0]



  • Hi,

    I think what you are looking for is : " here":http://doc.qt.io/qt-5/qsqlquery.html#approaches-to-binding-values


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.