B
B
belkakiller2018-10-30 17:57:40
Qt
belkakiller, 2018-10-30 17:57:40

Why is text not outputting from Sqlite database in QT creator?

<b>Сам Код </b><i></i>
#include "dreaminfo.h"
#include "ui_dreaminfo.h"
#include "info.h"

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

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

void DreamInfo::on_pushButton_clicked()
{
    Info drem;
    drem.setModal(true);
    drem.exec();
}

void DreamInfo::on_pushButton_7_clicked()
{


    //Подключаем базу данных
   QSqlDatabase db;
   db = QSqlDatabase::addDatabase("QSQLITE");
   db.setDatabaseName("tehno.db");
   db.open();

   //Осуществляем запрос
   QSqlQuery query;
   query.exec("SELECT name FROM People");

   //Выводим значения из запроса
   while (query.next())
   {
   QString name = query.value(0).toString();
   ui->textBrowser->insertPlainText( name+ "\n");
}

}

The error itself when clicking on the button text output: QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ananiev, 2018-10-30
@SaNNy32

Because here is https://stackoverflow.com/questions/25483218/handl...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question