Hi guys

My Code is something like this

Qt Code:
  1. static bool DBConnection ::createODBC_Connection()
  2. {
  3. m_db = QSqlDatabase::addDatabase("QODBC");
  4.  
  5. m_db.setDatabaseName( "Test_DataSourceName" ); //DSN created in ControlPanel=> Administrative Tools ODBC Connection => System DSN =>..ADD
  6.  
  7. m_db.setConnectOptions ("SQL_ATTR_ODBC_VERSION=SQL_OV_ODBC3");
  8. if (! m_db.open())
  9. {
  10. return false;
  11. }
  12. return true;
  13. }
To copy to clipboard, switch view to plain text mode 

Now am using this code in main.cpp like this

Qt Code:
  1. int main(int argc, char *argv[])
  2. {
  3. QApplication a(argc, argv);
  4.  
  5. if( ! DBConnection::createODBC_Connection() )
  6. {
  7. QMessageBox::information( 0 ,"" , DBConnection::getDBErrorInfo() );
  8. return 1;
  9. }
  10.  
  11. MainWindow w;
  12. w.show();
  13. return a.exec();
  14. }
To copy to clipboard, switch view to plain text mode 


For testing this code i have created class MainWindow and put the code like this
in the constructor itself
Qt Code:
  1. #include <QSqlQuery>
  2. #include <QMessageBox>
  3. #include <QSqlError>
  4.  
  5. MainWindow::MainWindow(QWidget *parent)
  6. : QMainWindow(parent), ui(new Ui::MainWindowClass)
  7. {
  8. ui->setupUi(this);
  9. //TEST_BEGIN
  10. QSqlQuery query("SELECT name FROM employee where emp_id = 7");
  11. if( query.exec() )
  12. {
  13. if( query.next() ) //while (query.next())
  14. {
  15. QString empName = query.value(0).toString();
  16. this->setToolTip( empName );
  17. //QMessageBox::information( this ,"" ,empName );
  18. }
  19. }
  20. else
  21. {
  22. QMessageBox::information( this ," In Mainwindow::Mainwindow()" ,
  23. query.lastError().databaseText() +"\n" // Here i am getting ODBC //error "Function sequence error"
  24. // statement cann't be executed
  25.  
  26. + query.lastError().driverText() +"\n"
  27. + query.lastError().text() );
  28. }
  29. //TEST_END
  30.  
  31. }
To copy to clipboard, switch view to plain text mode 

When i am running my application i am getting following error ...
[ODBC Driver Manager] "Function sequence error"
[ODBC Driver Manager] can not execute statement
[ODBC Driver Manager] "Function sequence error" QODBC3 : unable to execute statement


MY Operating System = Windows XP
IDE = QtCreator Beta ( comes with qt library )
Database = Mysql
ODBC Driver = Mysql ODBC 3.51 Driver ( i can see it in Control panel )

Please correct me if am doing something wrong.

thanks in advance