PDA

View Full Version : Some Problem with Qt4 link to sql server 2000 Database



bangqianchen
29th August 2008, 12:43
I have fellow the step to compile qsql_odbc.cpp with no errno

cd %QTDIR%\src\plugins\sqldrivers\odbc
qmake -o Makefile odbc.pro
nmake

but when I connect to the database, it's failed,the fellowing is my source codes
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setHostName("8B6E96BF656249F");
db.setDatabaseName("ZGSS");
db.setUserName("sa");
db.setPassword("888888");

bool ok = db.open();
if(ok)
{
AskBox("Connect Ok");
}
else
{
QSqlError err = db.lastError();
AskBox(err.text().toAscii().data());
}
the database server name, username and password is ok,because I use the fellowing string connect to the database in a VC program, It works well.
"driver={SQL Server};Server=8B6E96BF656249F; DATABASE=ZGSS; UID=sa; PWD=888888"

the err code in Qt Program is here:
[Microsoft][ODBC ???????] ??????????????????? QODBC3: Unable to connect
some chinese character is not show correctly.can you tell me what's wrong?