Results 1 to 2 of 2

Thread: Entering variable in db

  1. #1
    Join Date
    Sep 2008
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Entering variable in db

    "insert into teacher(login_id,teacher_fname,teacher_lname)value s(" + ui.txtTeacherLogin->text() + "," + ui.txtTeacherFname->text() + "," + ui.txtTeacherLname->text() + ")";

    I want to add this variable(insert) into my table,but I need to pass it as string ,but i cannot able to convert them to string .any help appreciated
    Subrata

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Entering variable in db

    I'm not sure what you mean.
    Qt Code:
    1. ...
    2. QString insertQuery = "insert into teacher(login_id,teacher_fname,teacher_lname)value s(" + ui.txtTeacherLogin->text() + "," + ui.txtTeacherFname->text() + "," + ui.txtTeacherLname->text() + ")";
    3. ...
    4. QSqlQuery query(insertQuery);
    5. if (!query.exec())
    6. return;
    7. ...
    To copy to clipboard, switch view to plain text mode 
    or
    Qt Code:
    1. QSqlQuery query;
    2. query.prepare("insert into teacher(login_id,teacher_fname,teacher_lname) value s(?, ?, ?");
    3. query.addBindValue(ui.txtTeacherLogin->text() );
    4. query.addBindValue(ui.txtTeacherFname->text());
    5. query.addBindValue(ui.txtTeacherLname->text());
    6. if (!query.exec())
    7. return;
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. install help nedded.
    By aj2903 in forum Installation and Deployment
    Replies: 9
    Last Post: 13th November 2008, 07:57
  2. nmake error during .pro compiling
    By mattia in forum Installation and Deployment
    Replies: 5
    Last Post: 18th June 2008, 10:15
  3. System environment variable
    By fahlen in forum Qt Programming
    Replies: 4
    Last Post: 27th November 2007, 19:02
  4. Variable question
    By MarkoSan in forum General Programming
    Replies: 4
    Last Post: 15th March 2007, 14:59
  5. custom plugin designer property with out a variable?
    By high_flyer in forum Qt Programming
    Replies: 1
    Last Post: 15th March 2006, 19:11

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.