c++ - Prepared Statement in MySQL Connector -
i want prepared statement this:
pstmt=conn->preparestatement("update partidos set i?=? id=?"); pstmt->setint(1,lazo); pstmt->setstring(2,texto[lazo]); pstmt->setint(3,var); pstmt->execute();
"lazo" variable in loop, texto[lazo] variable , var int variable.
when run query, throws exception: "you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'i?=? id=?' @ line 1".
it seems doesn't replace '?'.
i tried stringstreams, problem didn't fix.
thanks.
finally opted this.
stringstream stmtvar; stmtvar << "update partidos set minuto" << lazo << "='" << texto[lazo] << "' id=" << var; stmt->executeupdate(stmtvar.str());
it worked perfectly
Comments
Post a Comment