急求各位大神,我在QT中用sqlite数据库,创建了一个表格,然后进行查如何查询,可是为什么查询结果是木有
符合条件的元祖呢?我的代码如下:QSqlDatabasedb=QSqlDatabase::addDatabase("QSQLITE");db.setDatabaseNam...
符合条件的元祖呢?我的代码如下:
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("air_list");
if(!db.open())
exit(1);
QSqlQuery query(db);
query.exec("create air_bill (bill_id int primary key,room_id tinyint not null, start_time timestamp not null, end_time timestamp not null, rate float not null,total float not null)");
query.exec("create air_request ( request_id int primary key,room_id tinyint not null, request_time timestamp, des_tem float not null,des_speed tinyint not null)");
query.exec("create air_service (service_id int primary key,room_id tinyint not null, start_time timestamp not null, end_time timestamp not null, cur_tem float not null,des_tem,des_speed tinyint not null)");
query.exec("insert into air_request valus(1,1,null,23.5,2)");
QSqlTableModel* model = new QSqlTableModel;
model->setTable("air_request");
model->setFilter("room_id=1");
model->select(); 展开
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("air_list");
if(!db.open())
exit(1);
QSqlQuery query(db);
query.exec("create air_bill (bill_id int primary key,room_id tinyint not null, start_time timestamp not null, end_time timestamp not null, rate float not null,total float not null)");
query.exec("create air_request ( request_id int primary key,room_id tinyint not null, request_time timestamp, des_tem float not null,des_speed tinyint not null)");
query.exec("create air_service (service_id int primary key,room_id tinyint not null, start_time timestamp not null, end_time timestamp not null, cur_tem float not null,des_tem,des_speed tinyint not null)");
query.exec("insert into air_request valus(1,1,null,23.5,2)");
QSqlTableModel* model = new QSqlTableModel;
model->setTable("air_request");
model->setFilter("room_id=1");
model->select(); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询