if(QSqlDatabase::contains("qt_sql_default_connection"))
db = QSqlDatabase::database("qt_sql_default_connection");
else
db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("qq.db");
if(!db.open())
{
QMessageBox::warning(NULL, "Open DB", tr("Open DB error:%1").arg(db.lastError().text()));
}
QSqlQuery query;
query.prepare("create table user(id varchar(15) not null primary key,passwd varchar(15) not null,nickname varchar(15) null)");
if( !query.exec() )
{
QMessageBox::warning(NULL, "Create Table", tr("Create Table error:%1").arg(query.lastError().text()));
}
提示:Create Table error:No query Unable to fetch row
海绵宝宝撒
相关分类