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


MB va MBBTning asosiy tushunchalari


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

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.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