sqlite - How to insert a string containing '%' using QSqlQuery? -


i trying insert string contains '%' using qsqlquery getting error of type qsqlerror::transactionerror message

"near "%": syntax error unable execute statement" 

i have tried several ways escape "%" still getting error message. please see code snippet below.

query.exec(qstring("insert my_table (name, address) values (\"%1\", \"%2\")")                   .arg("harry", "#302%%1,...")); 

in place of "%%", have tried "\%", "\%", still didn't work , having same error message.

in sql, strings delimited ', not ".

anyway, should use parameters:

query.prepare("insert my_table (name, address) values (?, ?)"); query.addbindvalue("harry"); query.addbindvalue("#302%%1,..."); query.exec(); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -