The following is the sql statement
以下是sql语句
QString myQuery = "UPDATE myTable SET myAttr = :myAttr WHERE ID = 1";
//m_query is a QSqlQuery object pointer
m_query->prepare(myQuery);
QString value = "some value";
m_query->bindValue(":myAttr", QVariant(value)) ;
m_query->exec();
But when I print the executedQuery, it shows the value for **myAttr = ?**
The execution doesn't incur any complain about the bindValue(). Anyone aware what's going on here? I am using QT5.2.1 MinGW_32bits Thanks in advance.
执行不会引起任何关于bindValue()的抱怨。任何人都知道这里发生了什么?我正在使用QT5.2.1 MinGW_32bits在此先感谢。
1 个解决方案
#1
1
I have solved the problem using the following:
我使用以下方法解决了这个问题:
change the :myAttr to :MYATTR
and when you bind the value, follow the same format.
绑定值时,请遵循相同的格式。
m_query->bindValue(":MYATTR", QVariant(value)) **strong text**
I think it is an issue for newer version of QTCreator.
我认为这对于较新版本的QTCreator来说是一个问题。
#1
1
I have solved the problem using the following:
我使用以下方法解决了这个问题:
change the :myAttr to :MYATTR
and when you bind the value, follow the same format.
绑定值时,请遵循相同的格式。
m_query->bindValue(":MYATTR", QVariant(value)) **strong text**
I think it is an issue for newer version of QTCreator.
我认为这对于较新版本的QTCreator来说是一个问题。