Results 1 to 3 of 3

Thread: Using qsqlrecord?

  1. #1
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Question Using qsqlrecord?

    hi at this time im using QT3,
    can i use qsqlrecord as temporary table from my database so that i can avoid querying every time i need some record?

    1.i will create a qsqlrecord with the exact fields and values(data) of a table from the database? how?
    2.then i will create a qdatatable from my qsqlrecord but this time limiting the data in qdatatable to 100? how?
    3.If # 1 is possible can i do next() previous() last() first()? how?
    4.And last If # 1 is possible, if the table from the database was edited i want to somehow refresh my qsqlrecord, again with the same fields and values(data) of table (if # 1 is possible i can use that but I'm looking for faster way i.e qsqlrecord::refresh())

    note: if the database is big, it affects querying.

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using qsqlrecord?

    1.i will create a qsqlrecord with the exact fields and values(data) of a table from the database? how?
    Create a QSqlRecord Object and use void QSqlRecord::setValue ( const QString & name, const QVariant & val )

    2.then i will create a qdatatable from my qsqlrecord but this time limiting the data in qdatatable to 100? how?
    QSqlRecord can hold only one record. If I understand you right, I don't think this is possible with QSqlRecord.

    3.If # 1 is possible can i do next() previous() last() first()? how?
    You cannot do next() previous() etc on QSqlRecord, but you can get the field value using the field name or the index of the field.

    4.And last If # 1 is possible, if the table from the database was edited i want to somehow refresh my qsqlrecord, again with the same fields and values(data) of table (if # 1 is possible i can use that but I'm looking for faster way i.e qsqlrecord::refresh())
    I think you will need to use QSqlQuery along with QSqlRecord to achieve this.

  3. #3
    Join Date
    Dec 2007
    Posts
    129
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Question Re: Using qsqlrecord?

    Quote Originally Posted by munna View Post
    Create a QSqlRecord Object and use void QSqlRecord::setValue ( const QString & name, const QVariant & val )

    QSqlRecord can hold only one record. If I understand you right, I don't think this is possible with QSqlRecord.
    if i understand you right(same), your answer to #1 conflicts your answer to #2. If Qsqlrecord can only hold 1 record (do you mean one row of data?) then it is not the exact table with the all data from the table(to be copied) in the database (ex. a glass from a "glass with water") please clarify..

    answer to #1 QSqlRecord::setValue ( const QString & name, const QVariant & val ) can only be use in 1 row of data of 1 table or all the data from 1 table? do i need to use query.next() to insert all the data from one table?

    answer to #2 Setting Limit is possible in qdatatable, if i could just set a qsqlcursor or something like it, to the sqlrecord (but i need all the data from one table to be hold by sqlrecord)

    Quote Originally Posted by munna View Post
    You cannot do next() previous() etc on QSqlRecord, but you can get the field value using the field name or the index of the field.
    answer to #3 next() previous() last() and first() is possible using qdatabrowser (i just want the whole table to be hold by a sqlrecord if it possible then setting qsqlcursor or something like qsqlcursor, to it)

    what i want is to create a sqlrecord with the same fields and data with one table from the database.
    Then instead of using query statements i will just manipulate the sqlrecord.

    But again i cant pass qsqlrecord (if the 1st problem was solve) to qdatatable or qdatabrowser, am i right about this?? or it is possible to pass qsqlrecord to qdatatable or qsqldatabrowser..


    if not, i need to use qsqlcursor(or something like it) but instead of querying to database it will select all the data of sqlrecord since manipulation can be done by qdatatable and qdatabrowser.
    Last edited by triperzonak; 23rd July 2008 at 16:06.

Similar Threads

  1. QSqlRecord setValue doesn't set the value
    By sgmurphy19 in forum Qt Programming
    Replies: 1
    Last Post: 7th February 2008, 20:20
  2. QSqlRecord becoming invalid
    By mikro in forum Newbie
    Replies: 5
    Last Post: 3rd October 2006, 18:00
  3. QSqlRecord problem
    By stevey in forum Qt Programming
    Replies: 2
    Last Post: 24th September 2006, 22:32

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.