View Full Version : why get me this error about connection to SQL? help plz?
complexcoding
13th April 2013, 23:05
Hello
why get me this error about connection to SQL
my Code:
QSqlDatabase db=QSqlDatabase::addDatabase(QODBC);
Errror :(
D:\QtSDK\QtCreator\bin\Project7000\example\DBApp-build-desktop-Qt_4_8_0_for_Desktop_-_MinGW__Qt_SDK__Debug\..\DBApp\main.cpp:10: error: 'QODBC' was not declared in this scope
complexcoding
14th April 2013, 11:02
please Help me!!! :confused:
my code :
#include <QtCore/QCoreApplication>
#include <QtSql>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QString servername="HAL//SQLEXPRESS";
QString dbname="Booklet";
QSqlDatabase db=QSqlDatabase::addDatabase(QODBC);
db.setConnectOptions();
//QString dsn=QString("DRIVER=(SQL Native Client);SERVER=%1;DATABASE=%2;UID=sa;PWD=").arg(se rverName).arg(dbName);
QString dsn=QString("DRIVER=(SQL Native Client);SERVER=%1;DATABASE=%2;Trusted_Connection=Y es;").arg(servername).arg(dbname);
db.setDatabaseName(dsn);
if(db.open())
{
qDebug()<< "opened!";
db.close();
}
else{qDebug()<<"Error="<<db.lastError().text();}
return a.exec();
}
wysota
14th April 2013, 11:21
QSqlDatabase db=QSqlDatabase::addDatabase("QODBC");
complexcoding
14th April 2013, 12:14
thankful , But not loaded my Database ??? Why???
8937
my database in SQL server 2008 Pictures:
8938
thanks...
wysota
14th April 2013, 16:09
No idea, some missing odbc libraries, no QODBC driver compiled?
complexcoding
15th April 2013, 02:40
this is location my database?
I do not know where is the problem?
8940
ChrisW67
15th April 2013, 03:20
The problem is spelt out plainly in your first screen shot:
QSqlDatabase: QODBC driver not loaded
QSqlDatabase: available drivers:
You have no Qt database plugins available to your program. It cannot, therefore, load the QODBC driver you ask for.
If this is your build environment then you need to build the QODBC plugin
If this is a deployed program then you need to deploy the QODBC database plugin in the correct location.
complexcoding
15th April 2013, 04:55
everything is equal standard but i dont know where to put the lines ????
cd %QTDIR%\src\plugins\sqldrivers\odbc
qmake odbc.pro
nmake
Did I just say? thanks...
ChrisW67
15th April 2013, 06:06
You need to install the Qt source code for your Qt 4.8.x version if you have not got it already. %QTDIR% refers to the top of the source tree.
The commands need to be typed into a command prompt that is configured for Qt. The Qt SDK puts an icon to launch such a command prompt in the Windows Start menu so use that if you have it. If not, the Qt bin folder containing qmake.exe and the bin folder of your compiler must be on the PATH of a standard command prompt.
complexcoding
17th April 2013, 07:28
help me : this error is new when my project is Run...
cannot mix incompatible Qt Library<version 0x40704> with this library <version 0x40800>
8956
thanks...
if you say Qt 4.7 to Uninstall. I do not know how should I clean it ? can not find the icon 4.7?
wysota
17th April 2013, 07:30
You are mixing Qt libraries with different versions -- 4.7.4 and 4.8.0
complexcoding
17th April 2013, 08:07
How do I do this?
How do not mix?
Added after 10 minutes:
How do i do the work that this two version dont mix????
plz help...
Added after 24 minutes:
How do i do the work that this two version dont mix????
plz help...
wysota
17th April 2013, 08:40
How do I do this?
How do not mix?
You check versions of the libraries you are using and replace those from 4.7.4 with those from 4.8.0 or the other way round. If you built your sql plugin against 4.8.0 then you can't use it with 4.7.4 libraries.
complexcoding
17th April 2013, 11:16
This is a clip from Qt installation of my system and Run my project. Please download the File. thanks...
http://www.4shared.com/rar/ILnhLBUe/Qt_online.html
Added after 1 49 minutes:
Please help me!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.