Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: SQL-server-2005 C++ SQL , +
i have a server of windows server 2003 and its IP on my local network is

this server has SOL server 2005 express edition installed with user name sa and password amir
this SQL server has a database called amir
i want to connect to it from a Linux client on the same network
SQL server service using port 1617 on my server and i used this port to connect to the server using java
now i want to use QT C++ but i tried alot but my code don't want to work
this is my code
#include <QtCore/QCoreApplication>
#include <stdio.h>
#include <QTextStream>
using namespace std;
int main(int argc, char *argv[])
    QCoreApplication a(argc, argv);
    QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    bool test=db.isValid();//true
    db.setDatabaseName("DRIVER={SQL Server};SERVER=\\SQLEXPRESS:1617;DATABASE=amir");
        cout<<endl<<"not connected"<<endl;
        QString error=db.lastError().text();
        return false;
         return true;

every time i try this it out "not connected"

and the error is [unixODBC][Driver Manager]Data source name not found, and no default driver specified QODBC3: Unable to connect
using this parameters i can connect using java
so what is the wrong here? and if there is another fasting way to connect to the SQL server using qt c++ than ODBC driver please tell me
Posted 29-Sep-12 23:36pm
Edited 30-Sep-12 0:23am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 605
1 Maciej Los 225
2 Abhinav S 171
3 Richard Deeming 160
4 Suvendu Shekhar Giri 159
0 Sergey Alexandrovich Kryukov 9,623
1 OriginalGriff 9,095
2 Peter Leow 5,044
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 2,581

Advertise | Privacy | Mobile
Web03 | 2.8.150327.1 | Last Updated 30 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100