Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QODBC plugin compile
QtWS25 Last Chance

QODBC plugin compile

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 6.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Suths
    wrote on last edited by
    #1

    Hi everyone,

    Just wondering if anyone had any guidance for how to get QODBC to work inside visual studio 2008? So far I have downloaded Qt libraries 4.8.0 for Windows (VS 2008, 273 MB), and followed the online instructions for compiling the plugin, navigating to C:\Qt\4.8.0\src\plugins\sqldrivers\odbc, then running qmake odbc.pro, then nmake, however when i try to open a connection to the server I get
    'Error "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified QODBC3: Unable to connect" '

    Does any one have any ideas my code is as follows:
    @
    QSqlDatabase db = QSqlDatabase::addDatabase("QODBC", "MyDatabase");
    db.setHostName("LOCALHOST\SQLEXPRESS");
    db.setDatabaseName("test");
    db.setUserName("...");
    db.setPassword("...");

    if(db.open())
    {
    qDebug() << "Opened";
    db.close();
    }

    else
    qDebug() << "Error" << db.lastError().text();
    @

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Scylla
      wrote on last edited by
      #2

      Take a look "here":http://stackoverflow.com/questions/3060916/connection-mssql-with-qt.

      Hope this helps.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        francomartins
        wrote on last edited by
        #3

        Example of SQL Server Conection :

        @
        QSqlDatabase db = QSqlDatabase::addDatabase("QODBC", "MyDatabase");

        db.setDatabaseName("DRIVER={SQL Server};Server="+ipserver+";Database="+database+";Uid="+LoginName+";Port=1433;Pwd="+Pass+";WSID=");

        if(db.open())
        {
        qDebug() << "Opened";
        db.close();
        }
        else
        qDebug() << "Error" << db.lastError().text();
        @

        the WSID =. "is used to hide the client machine to the database server log

        [EDIT: code formatting, please use @-tags, Volker]

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Suths
          wrote on last edited by
          #4

          Thanks very much guys using your two responses i was able to fix my problem.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved