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);
Do'stlaringiz bilan baham: |