Hi everybody,
QT: 4.1.1
Compiler: MINGW 4.1
OS: WINXP
I am trying to connect to my local sql server, and i was not able:
db.setHostName("localhost");
db.setDatabaseName("DRIVER={SQL Server};SERVER=localhost;DATABASE=inventar;UID=rapha;PWD=raphaelf");
db.setUserName("rapha");
db.setPassword("raphaelf");
if(!db.open())
{
"not connected");
return false;
}
else
"connected");
return true;
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setHostName("localhost");
db.setDatabaseName("DRIVER={SQL Server};SERVER=localhost;DATABASE=inventar;UID=rapha;PWD=raphaelf");
db.setUserName("rapha");
db.setPassword("raphaelf");
if(!db.open())
{
QMessageBox::information(this, "Application name",
"not connected");
return false;
}
else
QMessageBox::information(this, "Application name",
"connected");
return true;
To copy to clipboard, switch view to plain text mode
Postgres connection works perfect:
db.setHostName("localhost");
db.setDatabaseName("DRIVER={PostgreSQL};SERVER=localhost;DATABASE=inventar;UID=rapha;PWD=raphaelf");
db.setUserName("rapha");
db.setPassword("raphaelf");
if(!db.open())
{
"not connected");
return false;
}
else
"connected");
return true;
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setHostName("localhost");
db.setDatabaseName("DRIVER={PostgreSQL};SERVER=localhost;DATABASE=inventar;UID=rapha;PWD=raphaelf");
db.setUserName("rapha");
db.setPassword("raphaelf");
if(!db.open())
{
QMessageBox::information(this, "Application name",
"not connected");
return false;
}
else
QMessageBox::information(this, "Application name",
"connected");
return true;
To copy to clipboard, switch view to plain text mode
What need i to connect to my sql server?
Bookmarks