2 Attachment(s)
how to show my sqlite database table on mainwindow with tableview widget
Hello All,
I am new to Qt and Sql database, now i am trying to create a sqlite database file and table.
And now i want to display the table in my mainwindow tableview....
Everything is ok but table is not displaying on the window...and no errors are comming...but when i clicked the submit button i got the error as shown in fig.
here is my code in attachments..
Thanks in advance..
Re: how to show my sqlite database table on mainwindow with tableview widget
Hello prasad1001
First of all, sorry for my english.
you have set the database name as "hari", so try this:
Code:
db.setDatabaseName("hari");
...
db.open();
...
or
in elsewhere.
false makes it not open a new database even if the database named "hari" does not exist.
Re: how to show my sqlite database table on mainwindow with tableview widget
Quote:
Originally Posted by
prasad1001
And now i want to display the table in my mainwindow tableview....
Everything is ok but table is not displaying on the window...and no errors are comming...but when i clicked the submit button i got the error as shown in fig.
Your QSqlTableModel does not have a database connection to work with, see second constructor argument.
Also the given table name is wrong (your table is not called "library data", just "library").
Cheers,
_
P.S.: A Sqlite database is a single file, you don't need username or password for that.
Re: how to show my sqlite database table on mainwindow with tableview widget
Thanks for the reply sir,
i was changed the table name and it works fine..
Thanks..