Results 1 to 4 of 4

Thread: Access Exsisting MSSQL databasse

  1. #1
    Join Date
    Jan 2011
    Location
    Sri Lanaka
    Posts
    64
    Thanks
    39
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Post Access Exsisting MSSQL databasse

    How can i get data from existing MSSQL database to a Qt applicaion.. im using sql with Qt for the first time....so
    if u can,please include a complete example code.. thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Access Exsisting MSSQL databasse

    You have to use a QODBC driver.

    for example code see the official documentation
    A camel can go 14 days without drink,
    I can't!!!

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

    deepal_de (13th July 2011)

  4. #3
    Join Date
    Jan 2011
    Location
    Sri Lanaka
    Posts
    64
    Thanks
    39
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Post Re: Access Exsisting MSSQL databasse

    WebDataBase is a DB thats in my MSSQLEXPRESS sever..

    Qt Code:
    1. QSqlDatabase qDb = QSqlDatabase::addDatabase("QODBC");
    2. qDb.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=WebDataBase.mdb");
    3. if (qDb.open())
    4. {
    5. QMessageBox::information(NULL,"Message", "DB open");
    6. }
    7. else
    8. {
    9. QMessageBox::information(NULL,"Message", "DB close");
    10. }
    To copy to clipboard, switch view to plain text mode 

    this doesn't work!
    how to chage the "qDb.setDatabaseName" to work with MSSQLEXPRESS

  5. #4
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Access Exsisting MSSQL databasse

    I never used MSSQL,

    however you have to set a correct ODBC configuration string (you used a Access Driver)

    I found this
    Qt Code:
    1. "Driver={SQLServer};Server=Your_Server_Name;Database=Your_Database_Name;Uid=Your_Username;Pwd=Your_Password;"
    To copy to clipboard, switch view to plain text mode 
    Last edited by mcosta; 13th July 2011 at 08:12. Reason: updated contents
    A camel can go 14 days without drink,
    I can't!!!

  6. The following user says thank you to mcosta for this useful post:

    deepal_de (13th July 2011)

Similar Threads

  1. Replies: 26
    Last Post: 13th September 2016, 19:38
  2. Access USB from Qt???
    By webquinty in forum Qt Programming
    Replies: 5
    Last Post: 6th June 2011, 08:40
  3. Replies: 0
    Last Post: 30th November 2010, 08:51
  4. Replies: 6
    Last Post: 25th November 2010, 21:02
  5. Replies: 1
    Last Post: 7th April 2010, 21:46

Tags for this Thread

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.