qtsql

QtSql application not working on the deployed machine

自闭症网瘾萝莉.ら 提交于 2019-12-02 13:06:56
I made a software in Qt/C++. I need to deploy it on Windows 7 (64 bit), which is also the host machine on which I developed the software. The problem is that my software can interact with the sqlite database on the developed machine, but when I try to deploy my software on some other machine, it can't interact with the database there. I tried to use "Run as Administrator", too, but it did not help. I also tried to use the compatibility mode as well. The database is located locally at C:\Users\username\Desktop\db1.sqlite , thus no networking or internet is required for my software to run

parameter count mismatch in parameterized query

安稳与你 提交于 2019-12-02 03:41:28
问题 I am using quite a lot of parameterized queries in my code for performance reasons. In short, some of them work, some don't. I initialize the query during construction of my database wrapper like this: QString querystring = QString("SELECT somevalue FROM sometable " "WHERE one_feature = :one_feature AND other_feature = :other_feature "); myquery = QSqlQuery(db); myquery.setForwardOnly(true); myquery.prepare(querystring); myquery is a QSqlQuery member variable of my database wrapper. Later on,

parameter count mismatch in parameterized query

纵然是瞬间 提交于 2019-12-02 02:09:00
I am using quite a lot of parameterized queries in my code for performance reasons. In short, some of them work, some don't. I initialize the query during construction of my database wrapper like this: QString querystring = QString("SELECT somevalue FROM sometable " "WHERE one_feature = :one_feature AND other_feature = :other_feature "); myquery = QSqlQuery(db); myquery.setForwardOnly(true); myquery.prepare(querystring); myquery is a QSqlQuery member variable of my database wrapper. Later on, in the function that wants to use this query, I do something like int db_wrapper::fetch_some_value

QtSQL + Sqlite and support for .size() function?

跟風遠走 提交于 2019-12-01 07:07:42
问题 I'm wondering does QtSql + Sqlite support QSqlQuery::size() function? 回答1: No, it does't. SQLite is one of the databases for which the size of the query is not directly available. BTW : A Google-query for "qt sqlite QSqlQuery size" had this StackOverflow question as first answer. 回答2: No, it doesn't. However, you can use last() and at() together to get the result. QSqlQuery q; q.exec("select * from table"); q.last(); qDebug() << q.at() + 1; 回答3: I also faced the same issue with SQLite and Qt.

How to make Qt aware of the QMYSQL driver

此生再无相见时 提交于 2019-12-01 04:03:42
I'm trying to access a MySql database from a Qt application but I get the following error: QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QSQLITE2 I find this very strange cause I have libqsqlmysql.so on my Qt folder. I have even tried to compile the MySql driver as a static plugin and add it to my .pro file as: QTPLUGIN += qsqlmysql But this also generates the same runtime error (it must've found the plugin cause there's no error compiling the application) What am I missing? I would like to avoid having to compile Qt from source cause this will have to work

How to make Qt aware of the QMYSQL driver

时光怂恿深爱的人放手 提交于 2019-12-01 01:46:12
问题 I'm trying to access a MySql database from a Qt application but I get the following error: QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QSQLITE2 I find this very strange cause I have libqsqlmysql.so on my Qt folder. I have even tried to compile the MySql driver as a static plugin and add it to my .pro file as: QTPLUGIN += qsqlmysql But this also generates the same runtime error (it must've found the plugin cause there's no error compiling the application)

What is the correct way of QSqlDatabase & QSqlQuery?

别来无恙 提交于 2019-11-29 20:08:38
I got confused with the manual , should i work like this: { QSqlDatabase db = QSqlDatabase::addDatabase (...); QSqlQuery query (db); query.exec (...); } QSqlDatabase::removeDatabase (...); As the document points out, query or db will be deconstructed automatically. But is that efficient ? Well , if i cache db inside a class , like the following: class Dummy { Dummy() { db = QSqlDatabase::addDatabase (...); } ~Dummy() { db.close(); } bool run() { QSqlQuery query (db); bool retval = query.exec (...); blabla ... } private: QSqlDatabase db; }; Sometimes i could see warnings like:

How do i use alias in where clause? [duplicate]

最后都变了- 提交于 2019-11-29 01:25:17
Possible Duplicate: Referring to a Column Alias in a WHERE Clause SELECT Trade.TradeId, Isnull(Securities.SecurityType,'Other') SecurityType, TableName, CASE WHEN SecurityTrade.SecurityId IS NOT NULL THEN SecurityTrade.SecurityId ELSE Trade.SecurityId END AS PricingSecurityID, sum(Trade.Quantity)OVER(Partition by Securities.SecurityType, SecurityTrade.SecurityId,Trade.Price, Buy,Long ) as sumQuantity, --added porfolio id for Getsumofqantity Trade.PortfolioId, Trade.Price, case when (Buy = 1 and Long = 1) then 1 when (Buy = 0 and Long = 0) then 1 else 0 end Position from Fireball_Reporting.

How do i use alias in where clause? [duplicate]

ぐ巨炮叔叔 提交于 2019-11-27 14:40:25
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Referring to a Column Alias in a WHERE Clause SELECT Trade.TradeId, Isnull(Securities.SecurityType,'Other') SecurityType, TableName, CASE WHEN SecurityTrade.SecurityId IS NOT NULL THEN SecurityTrade.SecurityId ELSE Trade.SecurityId END AS PricingSecurityID, sum(Trade.Quantity)OVER(Partition by Securities.SecurityType, SecurityTrade.SecurityId,Trade.Price, Buy,Long ) as sumQuantity, --added porfolio id for