How do you connect an Oracle database in C?

Answer

The following example creates an OracleConnection and sets some of its properties in the connection string.

    • Syntax based on .NET Framework version 1.1 **
#using <mscorlib.dll>
#using <System.dll>
#using <System.Data.dll>

using namespace System;
using namespace System::Data;
using namespace System::Data::OracleClient;

__gc class COracleConnection<br>
{
public:<br>
    void CreateOracleConnection( ) <br>
    {
        String* myConnString Oracle8i;Integrated Security new OracleConnection(     myConnString );

        myConnection->Open( );

        MessageBox::Show( String::Format( S"ServerVersion: {0}\nDataSource:{1}",
                    myConnection->ServerVersion,
                    myConnection->DataSource )
        );
        myConnection->Close();
    }
};
// This is the entry point for this application
#ifdef _UNICODE
int wmain( void )
#else
int main( void )
#endif
{    
    COracleConnection *pCOracleConnection = new COracleConnection();

    pCOracleConnection->CreateOracleConnection( );

    return 0;
}

Answer

You will use Oracle's API. Its called OCI for Oracle Call Interface -- use Google for details about its usage. You can also use OTL, which is the Oracle Template Library. Its much easier to use than OCI.

Answer

Additionally, you can use embedded sql and precompile this code into pure C using the Oracle Pro*C/C++ precompiler. Sample code exists in ORACLE_HOME/precomp/demo/proc and ORACLE_HOME/rdbms/demo. As Oracle is the largest database company in the world with the largest market share of enterprise s/w, you can bet there is code all over the internet to do what you want to do. Check the forums at otn.oracle.com, google (or other search engine), or asktom.oracle.com.

Improve Answer Discuss the question "How do you connect an Oracle database in C?" Watch Question

First answer by ID1135109744. Last edit by Iuhoosier88. Contributor trust: 49 [recommend contributor]. Question popularity: 33 [recommend question]

Research your answer:

Answers.com > Wiki Answers > Categories > Technology > Computers > Computer Databases > How do you connect an Oracle database in C?

Our contributors said this page should be displayed for the questions below. (Where do these come from)
If any of these are not a genuine rephrasing of the question, please help out and edit these alternates.
How can you connect oracle using cc?  How do you connect a database using C?  How can you connect to a database Oracle in C?  How do you connect Oracle database with C Plus Plus?