QT插入數據到數據庫報錯:"Column count doesn't match value count at row 1 QMYSQL: Unable to execute query"

原因:錯誤代碼舉例如下,在prepare語句中,table寫了3列,插入數據時,只插入了2列數據,表的列數和每行插入的數據個數不匹配。

query1.prepare("insert into table123(net,node,GND_or_VCC) values(:net,:node);");
QString temp_name = "aaa";
QString temp_node = "bbb";
query1.bindValue(":net",temp_name);
query1.bindValue(":node",temp_node);
if(!query1.exec())
{
       qDebug()<<"插入失敗!"<<query1.lastError().text();
}               
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章