Results 1 to 4 of 4

Thread: how to create a sql table {a int ,b int}, a &b are coming from user's input?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2013
    Posts
    5
    Qt products
    Qt5
    Platforms
    Windows

    Question how to create a sql table {a int ,b int}, a &b are coming from user's input?

    sorry for my poor english.
    i just want to get data from excel file(.xls) ,and use it to create a table like this: CREATE TABLE TEST( a INTEGER, b INTEGER); BUT a & b should come from excel. just like :
    Qt Code:
    1. query = QSqlQuery(db);
    2. query.prepare("INSERT INTO users(userName, passWord)"
    3. "VALUES(?, ?)");
    4. query.addBindValue(user);
    5. query.addBindValue(pwd);
    6. query.exec();
    To copy to clipboard, switch view to plain text mode 
    up there ,it is INSERT TO, BUT i want "CREATE", that is it!
    how to do this ?
    thanks in advance !thank you all!

  2. #2
    Join Date
    Sep 2013
    Posts
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: how to create a sql table {a int ,b int}, a &b are coming from user's input?

    is there anybody that can help me ? using QString can solve this, just like "a"+s; but i think maybe we can use "prepare ".But how to use that? help,help ,help !

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: how to create a sql table {a int ,b int}, a &b are coming from user's input?

    If you want to create atable then execute a CREATE TABLE SQL statement then insert the rows one-at-a-time in a loop. You have the INSERT so you just need the add the loop.

  4. #4
    Join Date
    Sep 2013
    Posts
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: how to create a sql table {a int ,b int}, a &b are coming from user's input?

    Quote Originally Posted by ChrisW67 View Post
    If you want to create atable then execute a CREATE TABLE SQL statement then insert the rows one-at-a-time in a loop. You have the INSERT so you just need the add the loop.
    thank YOU very much, and sorry for my poor english . But what you said is not what i want ,i want CREATE TABLE(a string, b string) ,but the "a" and "b" come from user's input ,if i get 'username" and "password " from user,i have to do this: CREATE TABLE(username string , password string) , now can you understand ?thank you again!

Similar Threads

  1. Replies: 9
    Last Post: 17th December 2012, 13:20
  2. ask user input in a while loop
    By Bennieboj in forum Newbie
    Replies: 5
    Last Post: 27th November 2011, 14:28
  3. User Input using QString
    By kumarpraveen in forum Newbie
    Replies: 4
    Last Post: 9th July 2010, 07:49
  4. problem with reading input from user
    By ketan007 in forum Qt Programming
    Replies: 1
    Last Post: 5th December 2009, 10:51
  5. QSplitter only resize from user input?
    By winston2020 in forum Qt Programming
    Replies: 1
    Last Post: 30th January 2009, 15:50

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.