Results 1 to 3 of 3

Thread: primary expression before '.'

  1. #1
    Join Date
    Jun 2014
    Posts
    30
    Thanks
    2
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default primary expression before '.'

    hi to all, I've centos 7.5 as client and centos 6.10 as mysql server in VM. I am trying to compile a simple program to login in MySQL server as follows :-
    Qt Code:
    1. void MyMainWindow::on_pushButtonLogin_clicked()
    2. {
    3. QString user = ui->lineEditUserName->text().trimmed();
    4. QString passwd = ui->lineEditPassword->text().trimmed();
    5.  
    6. db = connDB.connectDB(db, &user, &passwd);// <- here is problem
    7.  
    8. if(db->open())
    9. {
    10. QMessageBox::information(this, "Login", " Connection Succeeded");
    11. }
    12. else
    13. {
    14. QMessageBox::warning(this, "Login", "Coneection failure : " +db->lastError().text());
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 
    here connDB is class and having a static member function connectDB(QSqldatabase *db, QString *user, QString *passwd).
    error is :-
    Qt Code:
    1. mymainwindow.cpp:34: error: expected primary-expression before '.' token
    2. in db = connDB.connectDB(db, &user, &passwd);
    To copy to clipboard, switch view to plain text mode 
    code for connectDB :-
    Qt Code:
    1. QSqlDatabase * connDB::connectDB(QSqlDatabase *db, QString *uname, QString *passwd )
    2. {
    3. db->setDatabaseName("cbs");
    4. db->setHostName("serverora11gr2.db.net");
    5. db->setUserName(*uname);
    6. db->setPassword(*passwd);
    7. db->setPort(3306);
    8. return db;
    9. }
    To copy to clipboard, switch view to plain text mode 

    how to resolve this error.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,479
    Thanked 274 Times in 269 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: primary expression before '.'

    Qt Code:
    1. db = connDB::connectDB(db, &user, &passwd);
    To copy to clipboard, switch view to plain text mode 
    Read about the basics of C++.

  3. #3
    Join Date
    Jun 2014
    Posts
    30
    Thanks
    2
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: primary expression before '.'

    thanks a lot , you solved my problem.

Similar Threads

  1. Replies: 2
    Last Post: 16th January 2013, 10:41
  2. Replies: 5
    Last Post: 21st May 2011, 01:06
  3. Replies: 4
    Last Post: 3rd January 2011, 01:16
  4. Replies: 0
    Last Post: 29th June 2010, 13:35
  5. PRIMARY Selections
    By hayati in forum Newbie
    Replies: 9
    Last Post: 12th September 2006, 12:13

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.