Results 1 to 5 of 5

Thread: How can I send a SQLite :memory: database connection ?

  1. #1
    Join Date
    Oct 2008
    Location
    Europe
    Posts
    37
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question How can I send a SQLite :memory: database connection ?

    I have a non-default SQLite database connection created in a class. I .setdatabasename(:memory and then create a table.
    How do I access the SAME database from another class ?

    I tried sending the QSqlDatabase through a signal but the database became "blank" (no tables besides master).
    I tried QSqlDatabase sqlite = QSqlDatabase::database("already-established"); (within the new class) but with the same result.
    Is what I am trying to do logically wrong?


    psls dont tell me to use default connection.
    Thanks

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

    Default Re: How can I send a SQLite :memory: database connection ?

    QSqlDatabase::database("name") should work provided you opened the connection called "name" earlier on using addDatabase().
    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.


  3. #3
    Join Date
    Oct 2008
    Location
    Europe
    Posts
    37
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How can I send a SQLite :memory: database connection ?

    thank you for replying !
    Yes, thats what I read in the documentation. But it didnt :<. The connection appeared "the same", only there were no tables.

    If i pass QSqlDatabase *db then it appears to work.
    Last edited by georgep; 20th July 2009 at 00:59.

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

    Default Re: How can I send a SQLite :memory: database connection ?

    Can you show us the respective code? Especially the part where you create the connection and where you pass it to the other part of the application.
    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.


  5. #5
    Join Date
    Oct 2008
    Location
    Europe
    Posts
    37
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How can I send a SQLite :memory: database connection ?

    Heh, no need. I tried it again this morning and It worked as it supposed to. Dunno what was wrong last night. Sorry..

Similar Threads

  1. Threads and database connection
    By probine in forum Qt Programming
    Replies: 9
    Last Post: 7th August 2013, 08:30
  2. Replies: 1
    Last Post: 26th March 2009, 15:25
  3. cannot share the database connection!!!!
    By cbarmpar in forum Qt Programming
    Replies: 13
    Last Post: 23rd September 2008, 14:42
  4. Client/Server Error: BadIDChoice
    By 3nc31 in forum Qt Programming
    Replies: 5
    Last Post: 27th November 2007, 10:22
  5. SQLITE database problems
    By phoenix in forum Newbie
    Replies: 3
    Last Post: 30th April 2007, 21:38

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.