N
N
nika092017-04-29 16:52:10
MySQL
nika09, 2017-04-29 16:52:10

How to connect a database in QT and send data there?

Can you please tell me how to connect a database in QT and send there read values ​​entered by the user in the fields of the program?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ighor July, 2017-04-29
@nika09

Connect to base

QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL","CurrentThread");
db.setDatabaseName("table");
db.setUserName("username");
db.setHostName("localhost");
db.setPassword("123456");
db.open();

Send request
QSqlQuery query(db);
if(query.exec("SELECT * FROM `Users`"))
while(query.next())
{
//query.record().value("Name").toString();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question