Results 1 to 4 of 4

Thread: Problem using QSqlDatabase in Symbian

  1. #1
    Join Date
    Jul 2010
    Posts
    5
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Problem using QSqlDatabase in Symbian

    I’m trying to use the same code that works in my desktop and maemo platform into the symbian OS, but it is not working.
    I’m showing below the snipped of the code:

    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    2. db.setDatabaseName("E:/database/01");
    3. qDebug()<<"DB open: "<<db.open();
    To copy to clipboard, switch view to plain text mode 

    Result: “DB open: false”

    Is there anything to take in consideration in Symbian to create a database file?

  2. #2
    Join Date
    Apr 2011
    Posts
    124
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default Re: Problem using QSqlDatabase in Symbian

    Well, you might need to set the database name correctly. On Symbian database names must be coded Windows style, with the backslash. (Don't forget to double up, since backslash is the "escape" character.)

    And where is your database supposed to be? If you want it in the application-private directory you shouldn't code the drive designator or leading slash.

  3. #3
    Join Date
    Jul 2010
    Posts
    5
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Problem using QSqlDatabase in Symbian

    The Qt specification for paths uses "/" always regardless the targeted OS. In any case I have tried using backslash "\\" but it doesn't work either.

    I tested creating a file in this location "E:/database/01.txt" and it worked without a problem. So it shouldn't be a problem of the file system, but something related to the database back-end.

  4. #4
    Join Date
    Apr 2011
    Posts
    124
    Thanks
    1
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default Re: Problem using QSqlDatabase in Symbian

    Symbian is not your desktop. SQLite is not Qt. You should locate the file location with QFileInfo, then use absoluteFilePath to get the path, test that the directory exists with QDir::exists, check that the file exists (if it should) with QFile::exists, then convert slashes with QDir::toNativeSeparators.

    You can of course ignore this advice if you wish. I'm not your mother.

  5. The following user says thank you to DanH for this useful post:

    rahuldas (19th December 2011)

Similar Threads

  1. QSqlDatabase::removeDatabase problem
    By xeroblast in forum Qt Programming
    Replies: 1
    Last Post: 8th December 2010, 06:50
  2. Replies: 1
    Last Post: 9th September 2010, 16:49
  3. Sqlite & QSqlDatabase problem
    By rsimone in forum Newbie
    Replies: 5
    Last Post: 29th July 2009, 21:52
  4. QSqlDatabase driver problem
    By croscato in forum Qt Programming
    Replies: 2
    Last Post: 21st November 2008, 16:16
  5. QTimer and QSqlDatabase Problem
    By smtgra011 in forum Qt Programming
    Replies: 6
    Last Post: 4th July 2007, 16:37

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
  •  
Qt is a trademark of The Qt Company.