Solved QSqlQuery for ms access database
-
@mrshawn
There is no error but do not work. -
Can you write an example query that currently works for that use case ?
-
@sgaist
As i mentioned this one :QSqlQuery query ; query.prepare("SELECT * FROM names where name like ? "); query.addBindValue(st);
It works but i should write entire word i want to write a part of record in my case name record and it update QTableView
-
What I am asking for is an example without binding that is working. Once we have that it should be easier to come with a solution.
-
@sgaist
I have no idea. -
Hi, the use of % instead of * is the right way. The * is only for using it directly on ms access query.
WHat version of ms access are you using? could you post a screenshot of your database/table?
-
@ronaldviscarral
Thanks for your response here is my screenshot :
link imaget -
This post is deleted! -
@behruz-montazeri said in QSqlQuery for ms access database:
@sgaist
I have no idea.Something like
"SELECT * FROM names where name like '%foo%'"
to confirm that one is working properly. -
@sgaist
Yes that works.Then what should be inside the % % instead of foo for binding ???
what about binding ?? -
try this:
QSqlQuery query ; query.prepare("SELECT * FROM names where name like '%?%'" ); query.addBindValue("a");
-
I tested in Qt using access both 32 bits, this code works for me:
QString st = "a"; query->prepare("SELECT * FROM names WHERE name LIKE ?;"); QString criteria("%" + st + "%"); query->addBindValue(criteria);
-
@ronaldviscarral
Thank you very much it works now.