Qt how to use the Ole Db to linked database; need to use ActiveQt ?
-
windows7 32bit,qt5.0.1,MinGW4.7
1)Qt how to use the Ole Db to linked database; need to use ActiveQt ?
2)I want to operate the database dbf (vfp).Only to use odbc?
3)I use odbc to operate the dbf(vfp).Insert 4000 rows , each row contains two fields, each field char (20). i use 9644ms to Complete it.
the code like this
@
for(int i=0,i<4000,i++)
{
query.exec("insert into test (name,password) values ('TOM','123456789ABC')");
}
@
Is there other faster solution?I test q.execBatch() no faster,iuse 112543ms.Thank you!
-
You can try this solutions:
http://linux.techass.com/projects/xdb/
or
http://code.google.com/p/qtdbf/ (prety simple)
But this solutions does not use QtSql.
-
[quote author="TioRoy" date="1361471503"]You can try this solutions:
http://linux.techass.com/projects/xdb/
or
http://code.google.com/p/qtdbf/ (prety simple)
But this solutions does not use QtSql.
[/quote]
Thank you very much!
-
Windows has an ODBC driver for DBF files out of the box. Windows 7 also seems to have a Visual FoxPro ODBC driver out of the box. Qt has a QODBC driver available out of the box (although you might need to build it).
Sqlite, for example, inserts much faster if the inserts are done in a transaction.
@
if (db.transaction()) {
for(int i=0; i<4000; i++)
{
query.exec("insert into test (name,password) values ('TOM','123456789ABC')");
}
}
if (/* check for errors*/)
db.rollback();
else
db.commit();
@you can also save some time by preparing the query only once and using the bindValue() function in the loop.
@
QSqlQuery query(db);
bool ok = query.prepare(
"INSERT INTO test (name,password) "
"VALUES (:name, :password)"
);...
query.bindValue(":name", "a name");
query.bindValue(":password", "a password");
query.exec();
...
@ -
[quote author="ChrisW67" date="1361505069"]
Sqlite, for example, inserts much faster if the inserts are done in a transaction.
[/quote]Yes .it is very fast.Use sqlite(transaction) in my case i used 182ms .
[quote author="ChrisW67" date="1361505069"]
you can also save some time by preparing the query only once and using the bindValue() function in the loop.
[/quote]Practice, I am also using this method,but not fast enough.
Win7 default does not contain VFP ODBC.
I install vfp odbc and use it,I got Coding errors.
Gbk->utf8,read has error(like this 锟斤拷).
utf8->Gbk,write be OK.I think this is VFP ODBC 's bug.
Thank you very much!