Ma’lumotlar bazasiga ulanish jarayonlarini dasturlash. Mb va mbbtlari haqida tushunchalar


ui->tableView->setSelectionMode(QAbstractItemView::SingleSelection)


Download 1.14 Mb.
bet7/7
Sana15.11.2023
Hajmi1.14 Mb.
#1776994
1   2   3   4   5   6   7

ui->tableView->setSelectionMode(QAbstractItemView::SingleSelection);

ui->tableView->resizeColumnsToContents();

ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);

ui->tableView->horizontalHeader()->setStretchLastSection(true);

model->select(); // Делаем выборку данных из таблицы

//QTableView *view = new QTableView;

ui->tableView->setModel(model);

ui->tableView->show();

MB va MBBTning asosiy tushunchalari.

So’rovlar yaratish:

QSqlQuery query;

query.exec("SELECT name,salary FROM employee WHERE salary> 500");

while (query.next()) {

QString name = query.value(0).toString();

int salary = query.value(1).toInt();

qDebug() << name << salary;

}

MB va MBBTning asosiy tushunchalari.

Ma’lumotlarni Mbga yozish:

1) QSqlQuery query;

query.exec("INSERT INTO employee (id, name, salary) "

"VALUES (1001, 'Thad Beaumont', 65000)");

2) QSqlQuery query;

query.prepare("INSERT INTO employee (id, name, salary) "

"VALUES (:id, :name, :salary)");

query.bindValue(":id", 1001);

query.bindValue(":name", "Thad Beaumont");

query.bindValue(":salary", 65000);

query.exec();

MB va MBBTning asosiy tushunchalari.

Ma’lumotlarni Mbga yozish:

3) QSqlQuery query;

query.prepare("INSERT INTO employee (id, name, salary) "

"VALUES (?, ?, ?)");

query.addBindValue(1001);

query.addBindValue("Thad Beaumont");

query.addBindValue(65000);

query.exec();


Download 1.14 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling