Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
Quoted
Originally posted by _j
There I used the mysql.h avaliable in linux to make a connection.
Quoted
Originally posted by Christian
Hi,
we need some lines of code to be able to help you or a more detailed description where you problem is.
greets
k ,QMessageBox::Cancel,QMessageBox::NoButton);
k ,QMessageBox::Cancel,QMessageBox::NoButton);
k ,QMessageBox::Cancel,QMessageBox::NoButton);This post has been edited 1 times, last edit by "vinod_j" (May 16th 2004, 8:04pm)
|
|
Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
extern QString gDateVariable;
void form1::init()
{
QSqlDatabase * db = QSqlDatabase::addDatabase( "QMYSQL3" ) ;
db->setDatabaseName( "dbToConnectTo" ) ;
db->setHostName( "localhost" ) ;
db->setUserName( "dbUser" ) ;
db->setPassword( "dbPassword" ) ;
if ( !db->open() ) {
qDebug( "Failed opening database dbToConnectTo\nReason:" ) ;
qDebug( db->lastError().driverText() ) ;
qDebug( db->lastError().databaseText() ) ;
exit ( 1 ) ;
}
cursor = new QSqlSelectCursor( QString::null, db ) ;
}
void form1::getMaxValue()
{
cursor->exec( QString( "SELECT Max(Value) AS MaxVal FROM Profile "
"WHERE Month='%1' AND Weekday='%2' "
"GROUP BY Month,Weekday" )
.arg( Month).arg( Weekday) ) ) ;
if ( !cursor->next() ) {
qDebug( cursor->lastQuery() ) ;
return ;
}
MaxValInProfile = cursor->value( "MaxVal" ).toDouble() ;
}
|