Results 1 to 14 of 14

Thread: why get me this error about connection to SQL? help plz?

  1. #1
    Join Date
    Jan 2013
    Posts
    19
    Thanks
    11

  2. #2
    Join Date
    Jan 2013
    Posts
    19
    Thanks
    11

    Default Re: why get me this error about connection to SQL? help plz?

    please Help me!!!

    my code :

    Qt Code:
    1. #include <QtCore/QCoreApplication>
    2. #include <QtSql>
    3. #include <QDebug>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QCoreApplication a(argc, argv);
    8. QString servername="HAL//SQLEXPRESS";
    9. QString dbname="Booklet";
    10. QSqlDatabase db=QSqlDatabase::addDatabase(QODBC);
    11. db.setConnectOptions();
    12. //QString dsn=QString("DRIVER=(SQL Native Client);SERVER=%1;DATABASE=%2;UID=sa;PWD=").arg(se rverName).arg(dbName);
    13. QString dsn=QString("DRIVER=(SQL Native Client);SERVER=%1;DATABASE=%2;Trusted_Connection=Y es;").arg(servername).arg(dbname);
    14. db.setDatabaseName(dsn);
    15. if(db.open())
    16. {
    17. qDebug()<< "opened!";
    18. db.close();
    19. }
    20. else{qDebug()<<"Error="<<db.lastError().text();}
    21. return a.exec();
    22. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 14th April 2013 at 10:22. Reason: missing [code] tags

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: why get me this error about connection to SQL? help plz?

    Qt Code:
    1. QSqlDatabase db=QSqlDatabase::addDatabase("QODBC");
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. The following user says thank you to wysota for this useful post:

    complexcoding (14th April 2013)

  5. #4
    Join Date
    Jan 2013
    Posts
    19
    Thanks
    11

    Default Re: why get me this error about connection to SQL? help plz?

    thankful , But not loaded my Database ??? Why???
    Error.jpg

    my database in SQL server 2008 Pictures:
    1database.PNG

    thanks...

  6. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: why get me this error about connection to SQL? help plz?

    No idea, some missing odbc libraries, no QODBC driver compiled?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. The following user says thank you to wysota for this useful post:

    complexcoding (15th April 2013)

  8. #6
    Join Date
    Jan 2013
    Posts
    19
    Thanks
    11

    Default Re: why get me this error about connection to SQL? help plz?

    this is location my database?
    I do not know where is the problem?

    localBank.jpg

  9. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,728
    Thanks
    13
    Thanked 1,608 Times in 1,535 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: why get me this error about connection to SQL? help plz?

    The problem is spelt out plainly in your first screen shot:
    QSqlDatabase: QODBC driver not loaded
    QSqlDatabase: available drivers:
    You have no Qt database plugins available to your program. It cannot, therefore, load the QODBC driver you ask for.

    If this is your build environment then you need to build the QODBC plugin
    If this is a deployed program then you need to deploy the QODBC database plugin in the correct location.

  10. The following user says thank you to ChrisW67 for this useful post:

    complexcoding (15th April 2013)

  11. #8
    Join Date
    Jan 2013
    Posts
    19
    Thanks
    11

    Default Re: why get me this error about connection to SQL? help plz?

    everything is equal standard but i dont know where to put the lines ????

    cd %QTDIR%\src\plugins\sqldrivers\odbc
    qmake odbc.pro
    nmake

    Did I just say? thanks...

  12. #9
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,728
    Thanks
    13
    Thanked 1,608 Times in 1,535 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: why get me this error about connection to SQL? help plz?

    You need to install the Qt source code for your Qt 4.8.x version if you have not got it already. %QTDIR% refers to the top of the source tree.

    The commands need to be typed into a command prompt that is configured for Qt. The Qt SDK puts an icon to launch such a command prompt in the Windows Start menu so use that if you have it. If not, the Qt bin folder containing qmake.exe and the bin folder of your compiler must be on the PATH of a standard command prompt.

  13. The following user says thank you to ChrisW67 for this useful post:

    complexcoding (15th April 2013)

  14. #10
    Join Date
    Jan 2013
    Posts
    19
    Thanks
    11

    Default Re: why get me this error about connection to SQL? help plz?

    help me : this error is new when my project is Run...
    cannot mix incompatible Qt Library<version 0x40704> with this library <version 0x40800>

    untitled.PNG

    thanks...

    if you say Qt 4.7 to Uninstall. I do not know how should I clean it ? can not find the icon 4.7?

  15. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: why get me this error about connection to SQL? help plz?

    You are mixing Qt libraries with different versions -- 4.7.4 and 4.8.0
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  16. #12
    Join Date
    Jan 2013
    Posts
    19
    Thanks
    11

    Default Re: why get me this error about connection to SQL? help plz?

    How do I do this?
    How do not mix?


    Added after 10 minutes:


    How do i do the work that this two version dont mix????
    plz help...


    Added after 24 minutes:


    How do i do the work that this two version dont mix????
    plz help...
    Last edited by complexcoding; 17th April 2013 at 07:07.

  17. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: why get me this error about connection to SQL? help plz?

    Quote Originally Posted by complexcoding View Post
    How do I do this?
    How do not mix?
    You check versions of the libraries you are using and replace those from 4.7.4 with those from 4.8.0 or the other way round. If you built your sql plugin against 4.8.0 then you can't use it with 4.7.4 libraries.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  18. #14
    Join Date
    Jan 2013
    Posts
    19
    Thanks
    11

    Default Re: why get me this error about connection to SQL? help plz?

    This is a clip from Qt installation of my system and Run my project. Please download the File. thanks...
    http://www.4shared.com/rar/ILnhLBUe/Qt_online.html


    Added after 1 49 minutes:


    Please help me!
    Last edited by complexcoding; 17th April 2013 at 10:16.

Similar Threads

  1. QLocalSocket connection error
    By David_ in forum Qt Programming
    Replies: 4
    Last Post: 4th December 2012, 14:26
  2. error while execution duplicate connection name
    By khadija123 in forum Qt Programming
    Replies: 1
    Last Post: 13th April 2012, 14:59
  3. Replies: 0
    Last Post: 2nd September 2011, 11:52
  4. Error signal connection between 2 classes
    By mattia in forum Newbie
    Replies: 6
    Last Post: 31st October 2007, 09:36
  5. Replies: 3
    Last Post: 22nd June 2006, 16:27

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.