Results 1 to 7 of 7

Thread: write Records from DB to a binary file based on DB fields Size

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2013
    Posts
    33
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default write Records from DB to a binary file based on DB fields Size

    Hi,
    i have a query regarding where it has involvement of database and Qt. So here i go
    I have created a table with some columns which stores different data types.
    I need to read them and write to a binary file directly from database without having any intermediate structures.I need to write in hex format in to binary file. Say if i read a value from db as -80 which i stored as an int in database. i need to write it as 4 byte hex value to a file.Here is a part of code

    Qt Code:
    1. QFile output_file("xyz.dat");
    2. output_file.open(QIODevice::ReadWrite);
    3. QDataStream stream(&output_file);
    4.  
    5. while(query.next())
    6. {
    7.  
    8. for(int i=1;i<20;i++){
    9. byteArray.append(query.value(i));
    10. qDebug() << "Record Read :" <<byteArray.at(i);
    11. }
    12. }
    13. output_file << byteArray.toHex();
    To copy to clipboard, switch view to plain text mode 

    Please let me know ur thots.Thaks in Advance
    Regards
    Bala B
    Last edited by anda_skoa; 26th February 2017 at 09:10. Reason: missing [code] tags

Similar Threads

  1. Replies: 6
    Last Post: 10th June 2012, 19:43
  2. Replies: 2
    Last Post: 2nd November 2010, 05:15
  3. Replies: 0
    Last Post: 26th October 2010, 17:59
  4. How to write a QList into a binary file?
    By Lawand in forum Qt Programming
    Replies: 23
    Last Post: 15th June 2009, 10:04
  5. Writing Log Records To A Log File
    By vermarajeev in forum Qt Programming
    Replies: 9
    Last Post: 20th March 2007, 13:08

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.