具体的情况是,一个library的数据库其中有3张表,1、library_content 2、employee 3、book
利用关系数据库Qsqlrelationtablemodel将library_content 中的员工号列 与 employee的员工名字建立关系,library_content 中的图书编号列 与 book的图书名字建立关系。
问题,
使用 qsqlquery 写入sql语句添加book记录 具体语句如下:
QSqlQuery query;
insert_result = query.prepare("INSERT INTO shimen_book (shimen_book_id, shimen_book_name,shimen_book_ISDN,"
"shimen_book_price, shimen_book_class, shimen_book_class_num ) "
"VALUES (" + QString::number(last_num + 1)
+ ", '"
+ current_item_content.current_book_name
+ "', '"
+ current_item_content.current_book_ISDN
+ "', '"
+ current_item_content.current_book_price
+ "', '"
+ current_item_content.current_book_class
+ "', '"
+ current_item_content.current_book_class_num
+ "')");
query.exec();
执行后,在book的 tableview中可以马上看到加入的记录,但是关掉程序,重新开程序却发现,相关的数据内容没有写进数据库的book中,请问为何?使用的是QT4.4.0