Results 1 to 3 of 3

Thread: Connection with MySql

  1. #1
    Join Date
    Jul 2006
    Location
    Coimbatore,India
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Thumbs up Connection with MySql

    Hello friends,

    I am developing small database application with database MySql , actually database installed in remote system. I want to access database file example test.db from that remote system. I wrote the following lines in my application , but receive error .
    i.e can’t create TCP/IP socket (10093)QMYSQL:unable to connect.

    Qt Code:
    1. QSqlDatabase db1=QSqlDatabase::addDatabase("QMYSQL");
    2. db1.setHostName(“ Remote system ip address “);
    3. db1.setDatabaseName("test.db");
    4. db1.setUserName("root");
    5. db1.setPassword(NULL);
    6.  
    7. if(db1.open())
    8. QMessageBox::information(0,"DB","Access");
    9. else
    10. QMessageBox::warning(0,"DB","Not open");
    11. QSqlError err=db1.lastError();
    12. QString str=err.text();
    To copy to clipboard, switch view to plain text mode 

    How to make connection with database ?
    tool: Qt 4.1
    OS :Windows XP
    IDE : VC++.NET
    Last edited by wysota; 31st July 2006 at 09:41. Reason: Added [code] tags
    Vichu

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

    Default Re: Connection with MySql

    This looks more like a system error. What happens if you try to connect to that database using mysql console?

  3. #3
    Join Date
    Jul 2006
    Location
    Coimbatore,India
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Thumbs up Re: Connection with MySql

    Quote Originally Posted by wysota
    This looks more like a system error. What happens if you try to connect to that database using mysql console?

    hi,
    I was sloved that problem. Just add few codes in main cpp program. such as
    Inc files:
    #include <winsock.h> and create object for WSADATA and initialize startup module WSAStartup(0x0202, &wsadata) .

    Thanks for Your valuable reply.
    Vichu

Similar Threads

  1. connecting to MySQL through it's API
    By Philip_Anselmo in forum Installation and Deployment
    Replies: 20
    Last Post: 30th May 2006, 23:22
  2. How do I keep the client connection open ?
    By probine in forum Newbie
    Replies: 2
    Last Post: 25th March 2006, 19:06
  3. using Mysql: Ca't create TCP/IP socket
    By blackliteon in forum Qt Programming
    Replies: 6
    Last Post: 9th February 2006, 18:25
  4. Can I launch a dial-up connection in Windows?
    By gtthang in forum Qt Programming
    Replies: 3
    Last Post: 9th February 2006, 12:32
  5. Qt 4.1 OS on Windows & mysql
    By neeko in forum Installation and Deployment
    Replies: 10
    Last Post: 31st January 2006, 20:22

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.