LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   QT 3.3.2 & MySQL 4.0.20 (https://www.linuxquestions.org/questions/programming-9/qt-3-3-2-and-mysql-4-0-20-a-188583/)

sio 06-01-2004 04:38 PM

QT 3.3.2 & MySQL 4.0.20
 
I was trying to do a simple program sort of learning the ropes. I created a form, setup a database connection within project and did a browser that lists the phone number field and has a single button that says insert.

When i hit preview everything works like its supposed to.

So now i want to be able to compile it
First thing i found i needed to do was File->New->MainCPP and then choose my form.

Now it compiles but throws out tons of errors when i start the executable. So i found out that the program needs its own SQL connection, I went threw errors and errors of compiles but finally got it to compile with these additions to the main.cpp

Quote:

#include <qapplication.h>
#include <qsqldatabase.h>
#include <qdatatable.h>
#include <qsqlcursor.h>
#include "form1.h"

#define DRIVER "QMYSQL3"
#define DATABASE "qtmysql"
#define USER "root"
#define PASSWORD "mypassword"
#define HOST "gate"

int main( int argc, char ** argv )
{
QApplication a( argc, argv );
Form1 w;
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();

QSqlDatabase * defaultDB = QSqlDatabase::addDatabase( DRIVER );
defaultDB->setDatabaseName( DATABASE );
defaultDB->setUserName( USER );
defaultDB->setPassword( PASSWORD );
defaultDB->setHostName( HOST );
}
Thats all the code i have as the header file for the form is empty aside from one very long comment. when i compile everything starts without visual errors. but when starting from a command prompt i can see it cannot find the table within my qtmysql database. The table's name is ihldnc.

So my question is how do i get the qt stuff i inserted to use the sql connection that i have set up. I can't find any code relating to anything and im still learning the rope of ide's. I've exhausted nearly all the examples within the documentation. Any help would be appreciated.


All times are GMT -5. The time now is 01:18 AM.