Dear my friends...
I move forward to getting to know more about qt in
database application development.
I tried to make a very simple database application
qith QTable.
I have made the database connection successfully. I
found no error. If I click on "connect" it can connect
successfully because the connection name move to the
left hand column. The documentation in help menu said
it is so.
Compiled successfully.
but if I run the compiled code, i found this error
message as a prompt window comes:
"
An error occurred while accessing the database
".
And the error message on the linux console where I
executed "./book" are under below:
"
patrixlinux@patrix:~/arsip/proyek/qt/book> ./book
QSqlCursor::setName: unable to build record, does
'author' exist?
QSqlRecord::field: index out of range: 0
QSqlRecord::position: unable to find field forename
QSqlRecord::field: index out of range: -1
QSqlRecord::field: index out of range: 1
QSqlRecord::position: unable to find field surname
QSqlRecord::field: index out of range: -1
QSqlCursor::setName: unable to build record, does
'author' exist?
patrixlinux@patrix:~/arsip/proyek/qt/book>
"
the author table really exists. should do choosing the
database name as I do usually on PHP+MySQL (
mysql_select_db("192.168.23.21","patrix", "perjaka");
)?
I have tested to connect to my mysql server with the
same hostname, username and password and it's OK. I
also can do select query. I did testing with
mysql-client (mysql -h 192.168.23.21 -u patrix -p)
Please tell me where my mistake.
Thank you very much in advance.
ps: Here is what I've done underbelow:
patrixlinux@patrix:~/arsip/proyek/qt/book> ls
book.db book.pro depanform.ui depanform.ui~
main.cpp
patrixlinux@patrix:~/arsip/proyek/qt/book> qmake -o
Makefile book.pro
patrixlinux@patrix:~/arsip/proyek/qt/book> make
/usr/lib/qt3/bin/uic depanform.ui -o .ui/depanform.h
g++ -c -pipe -O2 -march=i586 -mcpu=i686
-fmessage-length=0 -Wall -fPIC -Wall -W -O2
-march=i586 -mcpu=i686 -fmessage-length=0 -Wall -fPIC
-DQT_NO_DEBUG -DQT_SHARED -DQT_TABLET_SUPPORT
-I/usr/lib/qt3/mkspecs/default -I. -I/usr/include
-I/usr/lib/qt3/include -I.ui/ -I. -I.moc/ -o
.obj/main.o main.cpp
/usr/lib/qt3/bin/uic depanform.ui -i depanform.h -o
.ui/depanform.cpp
g++ -c -pipe -O2 -march=i586 -mcpu=i686
-fmessage-length=0 -Wall -fPIC -Wall -W -O2
-march=i586 -mcpu=i686 -fmessage-length=0 -Wall -fPIC
-DQT_NO_DEBUG -DQT_SHARED -DQT_TABLET_SUPPORT
-I/usr/lib/qt3/mkspecs/default -I. -I/usr/include
-I/usr/lib/qt3/include -I.ui/ -I. -I.moc/ -o
.obj/depanform.o .ui/depanform.cpp
/usr/lib/qt3/bin/moc .ui/depanform.h -o
.moc/moc_depanform.cpp
g++ -c -pipe -O2 -march=i586 -mcpu=i686
-fmessage-length=0 -Wall -fPIC -Wall -W -O2
-march=i586 -mcpu=i686 -fmessage-length=0 -Wall -fPIC
-DQT_NO_DEBUG -DQT_SHARED -DQT_TABLET_SUPPORT
-I/usr/lib/qt3/mkspecs/default -I. -I/usr/include
-I/usr/lib/qt3/include -I.ui/ -I. -I.moc/ -o
.obj/moc_depanform.o .moc/moc_depanform.cpp
g++ -o book .obj/main.o .obj/depanform.o
.obj/moc_depanform.o -L/usr/lib/ -L/usr/lib/qt3/lib/
-L/usr/X11R6/lib/ -lqt -lXext -lX11 -lm
patrixlinux@patrix:~/arsip/proyek/qt/book> ls
Makefile book book.db book.pro depanform.ui
depanform.ui~ main.cpp
patrixlinux@patrix:~/arsip/proyek/qt/book> ./book
QSqlCursor::setName: unable to build record, does
'author' exist?
QSqlRecord::field: index out of range: 0
QSqlRecord::position: unable to find field forename
QSqlRecord::field: index out of range: -1
QSqlRecord::field: index out of range: 1
QSqlRecord::position: unable to find field surname
QSqlRecord::field: index out of range: -1
patrixlinux@patrix:~/arsip/proyek/qt/book> cat
main.cpp
#include