Results 1 to 7 of 7

Thread: QSQLITE problem with FOREIGN KEY

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2011
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: QSQLITE problem with FOREIGN KEY

    Quote Originally Posted by kamilus View Post
    hi everybody, i have a problem, when i compile such a code:

    query.exec("CREATE TABLE IF NOT EXISTS ProductTypeGroup(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)");
    query.exec("CREATE TABLE IF NOT EXISTS ProductType(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, low_level INTEGER )");

    everything is ok, the table called ProductType will be created

    but when i compile such a code:

    query.exec("PRAGMA foreign_keys = ON;");
    query.exec("CREATE TABLE IF NOT EXISTS ProductTypeGroup(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)");
    query.exec("CREATE TABLE IF NOT EXISTS ProductType(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, low_level INTEGER ), FOREIGN KEY (group) REFERENCES ProductTypeGroup(id)");

    i don't have any errors but table called ProductType won't be created

    Do You know what can be a problem??
    You have certainly errors, test the return value of QSqlQuery::exec
    You foreign key is bad (not exists).

  2. The following user says thank you to Kangs for this useful post:

    kamilus (25th April 2011)

Similar Threads

  1. Problem deploying qt application using qsqlite on Windows XP/7
    By anoraxis in forum Installation and Deployment
    Replies: 4
    Last Post: 8th April 2011, 14:18
  2. Foreign key ON
    By fantom in forum Qt Programming
    Replies: 0
    Last Post: 2nd March 2011, 11:32
  3. Replies: 1
    Last Post: 7th July 2008, 21:13
  4. FOREIGN KEY + QComboBox
    By eleanor in forum Qt Programming
    Replies: 1
    Last Post: 8th November 2007, 11:37
  5. QSqlite problem
    By dragon in forum Qt Programming
    Replies: 2
    Last Post: 11th April 2007, 03:02

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.