Results 1 to 2 of 2

Thread: How to dynamicly create a DSN by using Qt code?

  1. #1
    Join Date
    Aug 2008
    Posts
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to dynamicly create a DSN by using Qt code?

    I had developed a database on window platform with SQL Server as background database, now I want to restore the database in the program. As is known, we must close current connection before the operation. I know the SQL Server had a master database for default, I don't want to create this DSN by hand, Can I dynamicly create a dsn for the program? I find a example for Access database, but no example for SQL Server!

    Qt Code:
    1. ...
    2. db = QSqlDatabase::addDatabase("QODBC");
    3. db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=myaccessfile.mdb");
    4. if (db.open()) {
    5. // success!
    6. }
    7. ...
    To copy to clipboard, switch view to plain text mode 

  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: How to dynamicly create a DSN by using Qt code?

    You have to fill a QSqlDatabase object with appropriate data (hostname, port, login, pass, database name) using the dedicated methods.
    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.


Similar Threads

  1. Eclipse debugging: Unable to create variable object
    By PUK_999 in forum Installation and Deployment
    Replies: 0
    Last Post: 20th August 2009, 21:42
  2. Replies: 4
    Last Post: 1st May 2009, 11:00
  3. QDir create multiple dirs
    By ^NyAw^ in forum Qt Programming
    Replies: 2
    Last Post: 4th March 2009, 12:13
  4. Code editor
    By Michiel in forum Qt Programming
    Replies: 4
    Last Post: 14th March 2006, 17:20
  5. How to create directories??
    By paranoid_android in forum Qt Programming
    Replies: 3
    Last Post: 9th March 2006, 16:28

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.