This discussion is archived
2 Replies Latest reply: Mar 26, 2012 6:58 PM by 926197 RSS

Oracle11 XE and ODP / ODBC

926197 Newbie
Currently Being Moderated
I have Oracle 11 XE installed and I wish to configure ODBC (Or any method to allow Visual Studio 8 , and C++ to access the Oracle database)

I tried downloading and installing the ODT ( file: ODTwithODAC112030 ) but the ORACLE_HOME quoted was not the Oracle11 XE ORACLE_HOME.

I checked for previous installed oracle products, but the installer claimed it could not find any installed oracle products. But Oracle XE is working fine.

Any suggestions on how to proceed are welcome.

Regards

Jefe
  • 1. Re: Oracle11 XE and ODP / ODBC
    gdarling - oracle Expert
    Currently Being Moderated
    The 11g XE home should already come with ODBC and ODP.NET; there should be no need to add another home.

    The exception to that would be if you wanted to use Oracle Developer Tools for Visual Studio plugin for Server Explorer, in which case you'd need to go ahead and add a ODTwithODAC112030 install into a separate home. After doing that, you'd need to setup tnsnames.ora in that new home so the client can find the XE database.

    Hope it helps,
    Greg
  • 2. Re: Oracle11 XE and ODP / ODBC
    926197 Newbie
    Currently Being Moderated
    Thanks, I have the ODBC connection working, in the sense of being able to test the connection via SQL> connect system/password

    but, I need to run SQL commands from a C++ program against the Oracle 11 XE database, so what i need is C++ code examples along the following lines:

    1. Include the Header Files
    # include statements at the beginning of your programs:
    #include <sql.h>
    #include<sqltypes.h>
    #include<sqlext.h>

    2. Open a Connection to a Database
    Set the environment handle:
    SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &hdlEnv);

    Set ODBC Driver version:
    SQLSetEnvAttr(hdlEnv,SQL_ATTR_ODBC_VERSION,(void*)SQL_OV_ODBC30);

    Set the connection handle:
    SQLAllocHandle(SQL_HANDLE_DBC, hdlEnv, &hdlConn);

    Connect to the database:
    SQLConnect(hdlConn, (SQLCHAR*)dsnName,SQL_NTS,(SQLCHAR*)userID,SQL_NTS, (SQLCHAR*)passwd, SQL_NTS);

    Plus an example of assembling the SQL command for dispatch to Oracle via ODBC and accessing the reply (if any)


    I have looked in the documentation but have found nothing ...

    So i would appreciate being pointed in the right dirrection.

    Thanks

    Jefe

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points