Home >Database >Mysql Tutorial >mysql-QT连MySQL数据库插入操作问题

mysql-QT连MySQL数据库插入操作问题

WBOY
WBOYOriginal
2016-06-06 09:40:301674browse

mysqlqt

版本:QT5.2.1 MySQL5.0
代码如下:
代码一:query.exec("insert into text1(id,name,sex) values(1,'1','1')");
给数据库中text1表中插入数据,成功!

代码二:query.prepare("insert into text1(id,name,sex)""values(:id,:name,:sex)");
query.bindValue(":id",1);

query.bindValue(":name","1");
query.bindValue(":sex","1");

query.exec();
同代码一实现同一目标,但是为什么代码二没有错误提示,数据也没有插入到表中,求解!坐等大神指点!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn