Did you try skipping that DRIVER parameter in your database name?
Did you try skipping that DRIVER parameter in your database name?
hi wisota,
yes it not works
Qt Code:
db.setHostName("localhost"); db.setDatabaseName("inventar"); db.setUserName("rapha"); db.setPassword("raphaelf");To copy to clipboard, switch view to plain text mode
with the QT example SQL Browser, i was also not able to connect using ODBC
if i configure a "inventar.dsn" file in administrative tools (control panel winxp). I was able to connect OVER the SQL Browser Example but not from my app.
I will have in the future my database in a server. So i must be shure that on clients are no configurations needed or required. At my office where i work i have a app running that i can connect from client to server without to configure something special. (This program was programmed with QT3.3.4.)
I am using the same strategy to solve my problem, so i am not understanding whats wrong
Last edited by raphaelf; 26th February 2006 at 15:53.
Think DigitalGasoline
Did you make an entry in the odbc manager for your database?
hi wysota..
with my old program (QT3). I could connect me without to configure anything on the client and on the server like this:
Qt Code:
bool MainWindow::Verbinden() db->setHostName("pcpsr5"); db->setDatabaseName("DRIVER={SQL Server};SERVER=PCPSR5;DATABASE=inventar;UID=AdminCI;PWD=xxxxx"); db->setUserName("AdminCI"); db->setPassword("xxxxx"); if(!db->open()){ db->lastError().showMessage(); return false; } return true; }To copy to clipboard, switch view to plain text mode
Why should the same strategy not work with qt4
Think DigitalGasoline
Has Qt been built with ODBC support? What is the output of QSqlDatabase::drivers()?
The name of the driver is QODBC, not QODBC3.
Hi Dimitri.
I have installed QT4.1.1 not from binary..from the exe file
My output of QSqlDatabase::drivers() is: QODBC, QODBC3, QSQLITE
My last Post was a example for QT3 thats why QODBC3...
Example SQL Browser show me QSQLITE and QODBC and not QODBC3
Last edited by raphaelf; 26th February 2006 at 19:24.
Think DigitalGasoline
Do you get any messages from Qt? What exactly happens?
hi,
with following code i ca not read the message complete, but it say something about Error on connecting user "sa". Reason: no security SQL Server connection..
Qt Code:
db.setHostName("localhost"); db.setDatabaseName("DRIVER={SQL Server};SERVER=localhost;DATABASE=inventar;UID=sa;PWD=raphaelf"); db.setUserName("sa"); db.setPassword("raphaelf"); if(!db.open()){ return false; } return true;To copy to clipboard, switch view to plain text mode
If i try like following i get this error: Data Source Name not found and no default driver specified QODBC3 : Unable to connect
Qt Code:
.. db.setDatabaseName("inventar"); ..To copy to clipboard, switch view to plain text mode
Last edited by raphaelf; 26th February 2006 at 21:25.
Think DigitalGasoline
So the problem lies not in Qt or your application but in the database engine configuration. Try to connect with a different user, MS SQL may have non-secure connections for "sa" (system-admin) user disabled.
/************************************************** ******
**连接sqlserver
**
************************************************** *******/
bool UpgradeWizardPage::ConnectionSqlServer(QString user,QString password,QString host,QString database)
{
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC","QODBC1");//and connectionName
// db= QSqlDatabase::addDatabase("QODBC","QODBC1");
db.setDatabaseName("DRIVER={SQL Server};Server="+host+";Database="+database+";Uid= "+user+";Pwd="+password+";");
db.setHostName(host);
db.setUserName(user);
db.setPassword(password);
db.setConnectOptions("SQL_ATTR_CONNECTION_TIMEOUT= 60");
if (!db.open()) {
return false;
}else{
return true;
}
}
it's worked well,why you have programe?have you installed the sqlserver's odbc driver???
hi everybody,
I have tried at my Office to connect from client to our Server and it run Perfekt! We have MS SQL Server 7.0 installed there..hmmm..could by that ODBC doesent support the newer Version?
Thanks for all replies
here the code:
Qt Code:
db.setHostName("pcpsr5"); db.setDatabaseName("DRIVER={SQL Server};SERVER=pcpsr5;DATABASE=inventar;UID=sa;PWD=xxxxx"); db.setUserName("sa"); db.setPassword("xxxxx"); if(!db.open()) { "not connected"); return false; } else "connected"); return true;To copy to clipboard, switch view to plain text mode
Think DigitalGasoline
It could be that in the office the server is configured differently. Try to connect to the server without Qt, using regular sql console provided with the dbms (if there is one) to see if you can connect to the server at all.
Bookmarks