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. QSqlQuery Access violation by out of scope
QtWS25 Last Chance

QSqlQuery Access violation by out of scope

Scheduled Pinned Locked Moved Solved General and Desktop
qt 5.7sqlmysqlqsqlquery
17 Posts 6 Posters 6.6k Views
  • 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.
  • M Offline
    M Offline
    masterofeye
    wrote on last edited by
    #3

    Hi,
    there error message say not more then fatal error at 0x000... (ntdll.dll) in UnitTest.exe 0x000... Access Violation at read from pos 0x000....

    here the orignal text in german.
    Ausnahmefehler bei 0x000000007739F23C (ntdll.dll) in UnitTest.exe: 0xC0000005: Zugriffsverletzung beim Lesen an Position 0x000000202B2B0F98

    The finish call was just a try ;)

    jsulmJ 1 Reply Last reply
    0
    • M masterofeye

      Hi,
      there error message say not more then fatal error at 0x000... (ntdll.dll) in UnitTest.exe 0x000... Access Violation at read from pos 0x000....

      here the orignal text in german.
      Ausnahmefehler bei 0x000000007739F23C (ntdll.dll) in UnitTest.exe: 0xC0000005: Zugriffsverletzung beim Lesen an Position 0x000000202B2B0F98

      The finish call was just a try ;)

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #4

      @masterofeye Run through debugger and see what happens on the call stack

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        masterofeye
        wrote on last edited by
        #5

        Nothing what i can interpret as a failure:
        0_1481529136057_upload-50113657-6185-4eaa-9911-dcb20aa55a1f

        jsulmJ 1 Reply Last reply
        0
        • M masterofeye

          Nothing what i can interpret as a failure:
          0_1481529136057_upload-50113657-6185-4eaa-9911-dcb20aa55a1f

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #6

          @masterofeye Images do not work in the forum. Please upload it to somewhere and post a link. Or, even better, just copy paste here as text.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            masterofeye
            wrote on last edited by
            #7

            Really? Because I see the Image ... fantastic ..

            ntdll.dll!RtlFreeHeap()	Unknow
            kernel32.dll!HeapFree()	Unknow
            msvcr120.dll!000007feee2669d8()	Unknow
            Qt5Sql.dll!00000000612dae72()	Unknow
            qsqlmysql.dll!000007fefa8f1e05()	Unknow
            qsqlmysql.dll!000007fefa8f1d97()	Unknow
            Qt5Sql.dll!00000000612d15e4()	Unknow
            UnitTest.exe!SQLConstructor::MySQLInitialization() Zeile 35	C++
            UnitTest.exe!main(int argc, char * * argv) Zeile 23	C++
            
            kshegunovK 1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #8

              Hi,

              Did you check that your MySQL dlls are compiled with the same compiler as Qt ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • M Offline
                M Offline
                masterofeye
                wrote on last edited by
                #9

                As mentioned on the top, i took the libmysql.dll from the installation here mysql-connector-c-6.1.6-winx64 and the qsqlmysqld.dll from the msvc2013_64 installation. They should be compatible or ?

                jsulmJ 1 Reply Last reply
                0
                • M masterofeye

                  As mentioned on the top, i took the libmysql.dll from the installation here mysql-connector-c-6.1.6-winx64 and the qsqlmysqld.dll from the msvc2013_64 installation. They should be compatible or ?

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  @masterofeye said in QSqlQuery Access violation by out of scope:

                  They should be compatible or ?

                  Only if libmysql.dll was built with msvc2013_64.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  2
                  • M masterofeye

                    Really? Because I see the Image ... fantastic ..

                    ntdll.dll!RtlFreeHeap()	Unknow
                    kernel32.dll!HeapFree()	Unknow
                    msvcr120.dll!000007feee2669d8()	Unknow
                    Qt5Sql.dll!00000000612dae72()	Unknow
                    qsqlmysql.dll!000007fefa8f1e05()	Unknow
                    qsqlmysql.dll!000007fefa8f1d97()	Unknow
                    Qt5Sql.dll!00000000612d15e4()	Unknow
                    UnitTest.exe!SQLConstructor::MySQLInitialization() Zeile 35	C++
                    UnitTest.exe!main(int argc, char * * argv) Zeile 23	C++
                    
                    kshegunovK Offline
                    kshegunovK Offline
                    kshegunov
                    Moderators
                    wrote on last edited by
                    #11

                    @masterofeye said in QSqlQuery Access violation by out of scope:

                    UnitTest.exe!SQLConstructor::MySQLInitialization() Zeile 35	C++
                    UnitTest.exe!main(int argc, char * * argv) Zeile 23	C++
                    

                    What do you have around line 23 in your main() and what do you have around line 35 in SQLConstructor::MySQLInitialization()? It's not clear from the code snippet how the code you posted relates to these two locations.

                    Read and abide by the Qt Code of Conduct

                    1 Reply Last reply
                    2
                    • M Offline
                      M Offline
                      masterofeye
                      wrote on last edited by masterofeye
                      #12

                      So tested some more and put my code in the main function between of the QCoreApplication creation and the exec() function. And it works! I changed the QSqlQuery variable to a pointer and dellete it before the call of the exec().

                      When i put the this code now back in the class and execute the function, I get the error again.
                      The class inherits form QObject and uses the Q_OBJECT macro. Do I need anything else ?

                      sorry here the answer from @kshegunov question
                      main:

                      int main(int argc, char *argv[])
                      {
                      	QCoreApplication a(argc, argv);
                      
                      	SQLConstructor sql();
                      	sql.MySQLInitialization();   //line 13
                      
                      	QLocalSocket socket;
                      	socket.connectToServer("server");
                      	while (!socket.isOpen());
                      
                             RW::CORE::Unit u(&socket);
                             u.StartTest(RW::CORE::Util::Functions::PortalInfoShowDialog);
                             return a.exec();
                      }
                      ```in MySQLInitialization happens my code posted in the first post.
                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        masterofeye
                        wrote on last edited by masterofeye
                        #13

                        I found it !!! .... i linked against the Qt5Sql.lib and not against the Qt5Sqld.lib ..... GRRR
                        Thx for your help !!

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #14

                          Out of curiosity, how did that happen ?

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          VRoninV 1 Reply Last reply
                          0
                          • SGaistS SGaist

                            Out of curiosity, how did that happen ?

                            VRoninV Offline
                            VRoninV Offline
                            VRonin
                            wrote on last edited by
                            #15

                            @SGaist Happened to me too when I was using VS Express (which does not support the addins), you have to do the linking manually (and invoke moc and stuff in prebuild) and it's easy to get it wrong

                            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                            ~Napoleon Bonaparte

                            On a crusade to banish setIndexWidget() from the holy land of Qt

                            1 Reply Last reply
                            1
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #16

                              @VRonin I was thinking about something along this line. Just wanted to check whether it was that or a setup issue, an IDE quirk or something more exotic :)

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              mrjjM 1 Reply Last reply
                              1
                              • SGaistS SGaist

                                @VRonin I was thinking about something along this line. Just wanted to check whether it was that or a setup issue, an IDE quirk or something more exotic :)

                                mrjjM Offline
                                mrjjM Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on last edited by
                                #17

                                @SGaist
                                is VS express not excotic enough ? ;)

                                1 Reply Last reply
                                1

                                • Login

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