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 :-
void MyMainWindow::on_pushButtonLogin_clicked()
{
QString user
= ui
->lineEditUserName
->text
().
trimmed();
QString passwd
= ui
->lineEditPassword
->text
().
trimmed();
db = connDB.connectDB(db, &user, &passwd);// <- here is problem
if(db->open())
{
QMessageBox::information(this,
"Login",
" Connection Succeeded");
}
else
{
QMessageBox::warning(this,
"Login",
"Coneection failure : " +db
->lastError
().
text());
}
}
void MyMainWindow::on_pushButtonLogin_clicked()
{
QString user = ui->lineEditUserName->text().trimmed();
QString passwd = ui->lineEditPassword->text().trimmed();
db = connDB.connectDB(db, &user, &passwd);// <- here is problem
if(db->open())
{
QMessageBox::information(this, "Login", " Connection Succeeded");
}
else
{
QMessageBox::warning(this, "Login", "Coneection failure : " +db->lastError().text());
}
}
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 :-
mymainwindow.cpp:34: error: expected primary-expression before '.' token
in db = connDB.connectDB(db, &user, &passwd);
mymainwindow.cpp:34: error: expected primary-expression before '.' token
in db = connDB.connectDB(db, &user, &passwd);
To copy to clipboard, switch view to plain text mode
code for connectDB :-
{
db->setDatabaseName("cbs");
db->setHostName("serverora11gr2.db.net");
db->setUserName(*uname);
db->setPassword(*passwd);
db->setPort(3306);
return db;
}
QSqlDatabase * connDB::connectDB(QSqlDatabase *db, QString *uname, QString *passwd )
{
db->setDatabaseName("cbs");
db->setHostName("serverora11gr2.db.net");
db->setUserName(*uname);
db->setPassword(*passwd);
db->setPort(3306);
return db;
}
To copy to clipboard, switch view to plain text mode
how to resolve this error.
Bookmarks