Hi all,
I am quite new to QT programming. The problem is I want to transfer sql records which I get from firing select query in my database file to another class. I'm facing problems in doing so. Can anyone please help!!!!
thanks
Ambarish.
Hi all,
I am quite new to QT programming. The problem is I want to transfer sql records which I get from firing select query in my database file to another class. I'm facing problems in doing so. Can anyone please help!!!!
thanks
Ambarish.
How you are trying? QSqlRecord or something else.
Hi yogesh,
Thanks for the quick reply.
Here is how am I using QSqlRecord in my function.
QSqlQuery q;
QSqlRecord record;
q.prepare(QLatin1String("select * from calendarentry where date = ?"));
q.addBindValue(date);
if(!q.exec())
{
qDebug()<<"Error while executing select Query";
qDebug()<<q.lastError();
}
else
{
qDebug() << "Select Query fired Successfully on database for date in fetch day entries" << date;
while(q.next())
{
qDebug()<<"Entries in the table are"<<q.value(0).toInt();
qDebug()<<"Entries in the table are"<<q.value(1).toString();
qDebug()<<"Entries in the table are"<<q.value(2).toString();
qDebug()<<"Entries in the table are"<<q.value(3).toString();
qDebug()<<"Entries in the table are"<<q.value(4).toString();
qDebug()<<"Entries in the table are"<<q.value(5).toString();
qDebug()<<"Entries in the table are"<<q.value(6).toString();
}
record = q.record();
return (record);
Now how to fetch field data from this record or is there any other way......
And ya liked your tagline " daru vich pyar"
Thanks,
Ambarish
Very Easy , Use:
Qt Code:
To copy to clipboard, switch view to plain text mode
Have you ever mixed?![]()
sorry man. I'm still not able to get the field values.
qfield = record.field("date");
qDebug()<<"date record is"<<qfield.value().toString();
or
qDebug()<<"date record is"<<qfield;
the output is "date record is QVariant(, ) "
Have you ever mixed?
ya sometimes
Thanks
Ambarish
Use code tags for pasting code lines.
Can you try this and see the result.
Qt Code:
qfield = record.field("date"); if(qfield.isValid()){ qDebug()<<"Field is valid named : "<<qfield.name(); qDebug()<<"Field value is :"<<qfield.value().toString(); } else qDebug()<<"Field is invalid ";To copy to clipboard, switch view to plain text mode
Hi ,
This is the output I'm getting:
Field is valid named : "date"
Field value is : ""
Thanks,
Ambarish![]()
gotcha!!!!
thanks for your valuable help!!!!!
Bookmarks