Results 1 to 4 of 4

Thread: SQLite3 and Qt

  1. #1
    Join Date
    Feb 2009
    Posts
    13
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Red face SQLite3 and Qt

    Hi there folks!

    I've got a little big problem which is already giving me a huge headache...

    I am trying to establish a connection to a file database created using sqlite3, but for some reason I can't!

    I've first tried to use the following code:

    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    2. db.setHostName("localhost");
    3. db.setDatabaseName("medadmin");
    4. db.setUserName("****");
    5. db.setPassword("*****");
    To copy to clipboard, switch view to plain text mode 

    and it didn't work. After some research I found out that Sqlite3 doesn't use permissions on its databases and so I removed the last two lines of the above code (needless to say it didn't work).

    What am I doing wrong??? should I set the host name to the full path of the file???

    Thanks in advance,

  2. #2
    Join Date
    Mar 2008
    Posts
    141
    Thanks
    10
    Thanked 9 Times in 9 Posts

    Default Re: SQLite3 and Qt

    Hi,

    use the full path as the database name. You do not need to set the host as well.

  3. #3
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: SQLite3 and Qt

    You don't have to specify the user and password either, since sqlite doesn't support authorization.
    I'm a rebel in the S.D.G.

  4. #4
    Join Date
    Feb 2009
    Posts
    13
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Smile Re: SQLite3 and Qt

    Thank you very much!

Similar Threads

  1. Sqlite3 window problem
    By giusepped in forum Qt Programming
    Replies: 11
    Last Post: 7th November 2008, 02:18
  2. How can I save a QImage object into a SQLite3 database table?
    By danielperaza in forum Qt Programming
    Replies: 1
    Last Post: 27th March 2008, 05:39
  3. problem: inserting a BLOB into sqlite3 with QT4.3
    By oscar in forum Qt Programming
    Replies: 1
    Last Post: 18th November 2007, 12:38

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.