Create firebird database programmatically with Qt
-
Hi,
When you say create database do you mean generate/setup the tables ?
-
What did try (code wise) ?
What error did you get ?
Do you have the proper credentials on the server to create new databases ? -
Can you post the statement that you want to execute ?
-
I must execute a CREATE DATABASE because I need to create a database from the Qt code, but QSqlDriver does not have a create statement.
@
QString queryString;
queryString += "CREATE DATABASE";
queryString += " '" + path + "'";
queryString += " USER 'sysdba'";
queryString += " PASSWORD 'masterkey'";
queryString += " DEFAULT CHARACTER SET UNICODE_FSS";
@ -
Looks like there's a \ missing after sysdba
What error are you getting ?
-
Yes SGaist, but the error don not appear in this code. Is is just what I need to create. The error appears when I try to run the code below:
@
bool DB::conectarServidorFirebird(QSqlDatabase db)
{
bool retorno = true;db.setHostName("localhost"); db.setPassword("gui080381"); db.setUserName("sysdba"); //db.setPort(3050); if(db.open()) { retorno = true; } else { qDebug() << db.lastError(); retorno = false; } return retorno;
}
@It returns me the error:
QSqlError("-901", "Error opening database", "Can't access lock files' directory /tmp/firebird") -
Do you have the rights to access /tmp/firebird ?
-
What's your exact target setup ?
-
So you want standard user to be able to do privileged action ?
-
I need to be able to create a database from Qt programming. I can access databases but I cant create it directly from the code using firebird.
It returns me this error:
QSqlError("-902", "Error opening database", "cannot attach to password database")and sometimes this one:
QSqlError(”-901”, “Error opening database”, “Can’t access lock files’ directory /tmp/firebird”)I am using this code:
@
bool DB::conectarServidorFirebird(QSqlDatabase db)
{
bool retorno = true;db.setHostName("localhost"); db.setPassword("gui080381"); db.setUserName("sysdba"); //db.setPort(3050); if(db.open()) { retorno = true; } else { qDebug() << db.lastError(); retorno = false; } return retorno;
}
@ -
Looks more like a firebird setup problem