Results 1 to 15 of 15

Thread: Not getting all data from database through QNetworkAccessManager.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2013
    Posts
    142
    Thanks
    36
    Thanked 3 Times in 3 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Not getting all data from database through QNetworkAccessManager.

    I am trying to download all rows from a mysql table into sqlite using QNetworkAccessManager but it will not retrieve full data, more worse it retrieves random number of rows(134,135,220, 1409) but never full rows which in that tables are aprox. 4000;

    Url setting:
    Qt Code:
    1. void sinc::startNetworkRequest(){
    2. QNetworkAccessManager *manager=new QNetworkAccessManager(this);
    3. QNetworkRequest cerere;
    4. QNetworkReply *rasp;
    5.  
    6. cerere.setUrl(QUrl("http://webserverurl.php?param1=01&param2=01"));
    7. rasp=manager->get(cerere);
    8. connect(rasp,SIGNAL(readyRead()),this,SLOT(insertToTable()));
    9. connect(rasp,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(slotEroare(QNetworkReply::NetworkError)));
    10. }
    To copy to clipboard, switch view to plain text mode 

    Data retrieving slot:

    Qt Code:
    1. void sinc::insertToTable(){
    2. QByteArray baRasp=rasp->readAll();
    3. QString str(baRasp);
    4. QStringList listaDet,listaElemR;
    5. listaDet=str.split(";");
    6. QSqlQuery curatare,adaug;
    7.  
    8. curatare.exec("delete from destTable");
    9. for(int i=0; i<listaDet.size()-1; i++){
    10. listaElemR=listaDet[i].split(",");
    11. adaug.exec("insert into destTable values ("
    12. "'"+listaElemR[0]+"'"
    13. ",'"+listaElemR[1]+"'"
    14. ",'"+listaElemR[2]+"'"
    15. ",'"+listaElemR[3]+"'"
    16. ",'"+listaElemR[4]+"'"
    17. ",'"+listaElemR[5]+"'"
    18. ",'"+listaElemR[6]+"'"
    19. ",'"+listaElemR[7]+"'"
    20. ",'"+listaElemR[8]+"'"
    21. ",'"+listaElemR[9]+"'"
    22. ",'"+listaElemR[10]+"'"
    23. ",'"+listaElemR[11]+"'"
    24. ",'"+listaElemR[12]+"'"
    25. ",'"+listaElemR[13]+"'"
    26. ",'"+listaElemR[14]+"'"
    27. ")");
    28. }
    29. }
    To copy to clipboard, switch view to plain text mode 

    If I want to retrieve the number of rows from the webserver( through echo mysqli_num_rows(result)) I get the full number rows, so it isn't mysql's,php's or webserver's fault.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Not getting all data from database through QNetworkAccessManager.

    How many times You service readyRead signal ? You should read data until signal finished is emitted.

  3. The following user says thank you to Lesiok for this useful post:

    adutzu89 (19th June 2014)

Similar Threads

  1. Replies: 2
    Last Post: 6th April 2014, 11:07
  2. Post some data onto the local server by QNetworkAccessManager(Qt5)
    By stereoMatching in forum Qt Programming
    Replies: 2
    Last Post: 10th March 2014, 00:13
  3. Replies: 1
    Last Post: 29th September 2012, 19:49
  4. Replies: 0
    Last Post: 18th May 2011, 09:18
  5. HTTP Post from QNetworkAccessManager - no data sent
    By secureboot in forum Qt Programming
    Replies: 1
    Last Post: 13th April 2011, 18:46

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
  •  
Qt is a trademark of The Qt Company.