Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt how to use the Ole Db to linked database; need to use ActiveQt ?
Forum Updated to NodeBB v4.3 + New Features

Qt how to use the Ole Db to linked database; need to use ActiveQt ?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 4.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xisuosunboy
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • T Offline
      T Offline
      TioRoy
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xisuosunboy
        wrote on last edited by
        #3

        [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!

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          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();
          ...
          @

          1 Reply Last reply
          0
          • X Offline
            X Offline
            xisuosunboy
            wrote on last edited by
            #5

            [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!

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved