Mavzu: mb va mbbtlari haqida tushunchalar. Qt muhitidan turli mblariga ulanish usullari


MB va MBBTning asosiy tushunchalari


Download 1.12 Mb.
bet6/7
Sana01.04.2023
Hajmi1.12 Mb.
#1314961
1   2   3   4   5   6   7
Bog'liq
MARJONA-9,10

MB va MBBTning asosiy tushunchalari.

Accessga ulanish:

QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");

db.setHostName("bigblue");

db.setDatabaseName("flightdb");

db.setUserName("acarlson");

db.setPassword("1uTbSbAs");

bool ok = db.open();

MB va MBBTning asosiy tushunchalari.

Accessga ulanish:

Loyiha faylida:

QT += sql

Biror faylda:

QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");

qDebug() << db.drivers();

db.setHostName("localhost");

db.setDatabaseName("MSDB");

qDebug() << db.open();

MB va MBBTning asosiy tushunchalari.

Accessga ulanish:

QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");

db.setHostName("127.0.0.1");

db.setDatabaseName("Driver={Microsoft Access Driver (*.mdb, *.accdb)}SN=''BQ=C:\\database.accdb");

db.setUserName("root");

if(!db.open())

qDebug() << db.lastError().text();

else

qDebug() << "Connect!";

MB va MBBTning asosiy tushunchalari.

Ma’lumotlarni ko’rsatish:

QSqlTableModel model;

model.setTable("employee");

QTableView *view = new QTableView;

view->setModel(&model);

view->show();

MB va MBBTning asosiy tushunchalari.

Accessga ulanish:

#include

#include

QSqlDatabase db;

QSqlQueryModel *m=new QSqlQueryModel();

db = QSqlDatabase::addDatabase("QODBC3");

db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=baza.mdb");

if(!db.open())

{ QMessageBox::critical(this,tr("Ошибка"),db.lastError().text()); }

QSqlTableModel *model;

model = new QSqlTableModel(this);

model->setTable("ilmiy");

MB va MBBTning asosiy tushunchalari.

Accessga ulanish:

ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);


Download 1.12 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