Access dasturi yordamida malumotlar bazasi hosil qilish Olimboyeva Nilufar
tarix 20.10.2022 ölçüsü 0,93 Mb. #118460
MB loyiha Olimboyeva Nilufar MB va MBBTning asosiy tushunchalari. Ma'lumotlar bazasi (JB) - bu hisoblash tizimining xotirasida saqlanadigan va ma’lum bir predmet sohasidagi ob'ektlarning holati va ularning o'zaro aloqalarini aks ettirish uchun tuzilgan ma'lumotlar to'plamidir. Kompyuter ma'lumotlar bazalarida oddiy matnlardan (familiya, ism va manzil kabi) murakkab tuzilmalargacha, shu jumladan rasmlar , tovushlar xam saqlanishi mumkin. Ma'lumotlarni oldindan ma'lum bo'lgan formatda saqlash turli xil ishlov berish usullarini qo'llash orqali ma'lumotlarni kerakli formatda olish imkonini beradi. Ma'lumotlar bazasining ishlashi ma'mur(administrator) tomonidan ta'minlanadi. MB va MBBTning asosiy tushunchalari. QT da quyidagi MBBTlariga ulanish mumkin: QDB2 IBM DB2 (version 7.1 and above) QIBASE Borland InterBase QMYSQL MySQL QOCI Oracle Call Interface Driver QODBC Open Database Connectivity (ODBC) - Microsoft SQL Server and other ODBC-compliant databases QPSQL PostgreSQL (versions 7.3 and above) QSQLITE2 SQLite version 2 QSQLITE SQLite version 3 QSYMSQL SQLite version 3 for Symbian SQL Database QTDS Sybase Adaptive Server Note: obsolete from Qt 4.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); ui->tableView->setSelectionMode(QAbstractItemView::SingleSelection); ui->tableView->resizeColumnsToContents(); ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->tableView->horizontalHeader()->setStretchLastSection(true); //QTableView *view = new QTableView; ui->tableView->setModel(model); ui->tableView->show(); MB va MBBTning asosiy tushunchalari. So’rovlar yaratish: 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; } Institut yotoqxonasida yashovchi talabalar haqida ma’lumot beruvchi ma’lumotlar bazasi Jadvallar hosil qilish so’rovlar hosil qilish (Qidiruv so’rov) (Tanlash so’rov) oraliq bo’yicha saralash so’rov shartli so’rov Forma hosil qilish Master Form hosil qilish jadvallarni bog’lash Etiboringiz uchun raxmat! Dostları ilə paylaş: