Results 1 to 3 of 3

Thread: creating new sql database

  1. #1
    Join Date
    Apr 2010
    Posts
    10
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default creating new sql database

    Hello,

    I am working on a project currently to get my self more familiarized with qt+sqL. I would like the user to be able to press 'new' and when they do, qt will create a new database using sqL. Then the user can start modifying that database. They can save it and close it. Later they can come back and load that database or they can create another new one.

    I was wondering how i would go about this? I am not sure how to get qt to create the new database.

    Thanks for help in advance.

    EDIT::

    Actually, another question... i may know how to do this myself. If i were to use sqlite and i tried to open a connection to a non existant database, would it automatically create the database and then i could query the database to set up the tables and stuff? If that is the case, then i know how i would do this.
    Last edited by prolink007; 18th April 2010 at 16:08.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: creating new sql database

    If you using SQLite just set a file (it will be created if it does not exists). Then use simple SQL commands like
    sql Code:
    1. CREATE DATABASE database_name // only FOR MySql TO CREATE a DATABASE IN SQLite this IS the file.
    2. CREATE TABLE Persons
    3. (
    4. P_Id int,
    5. LastName varchar(255),
    6. FirstName varchar(255),
    7. Address varchar(255),
    8. City varchar(255)
    9. ) // creates a TABLE...
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to Lykurg for this useful post:

    prolink007 (18th April 2010)

  4. #3
    Join Date
    Apr 2010
    Posts
    10
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: creating new sql database

    Thats what i thought. I was looking at the docs for sqlite+qt and noticed that.

    Thanks for the assistance.

Similar Threads

  1. problem creating a mysql database
    By TonyB in forum Qt Programming
    Replies: 10
    Last Post: 23rd July 2010, 15:39
  2. How to find that, i am creating database first time
    By newtowindows in forum Qt Programming
    Replies: 4
    Last Post: 27th October 2009, 13:33
  3. Creating and Using Qdialog
    By tpf80 in forum Newbie
    Replies: 4
    Last Post: 14th March 2007, 10:06
  4. Help creating a PDF doc
    By Dark_Tower in forum Qt Programming
    Replies: 5
    Last Post: 10th December 2006, 12:43
  5. Creating Threads
    By machathu in forum Qt Programming
    Replies: 8
    Last Post: 28th February 2006, 05:41

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.