« Build a Web Application with JDeveloper 10g Using EJB, JPA, and JavaServer Faces (end product) | Main | Using ADF Business Components with Oracle ADF (end product) »

ODP.NET with Visual C++ 2008


Many developers still using C++ for some reasons. One of my customers is using VC++ but with open source database and he is not that happy with the database so he wants to change to Oracle database. This is a simple sample that I build for him with 1 button and 1 listbox.

When I was doing few lines of code for this sample I realize 2 not quite happy scenario in VC++; 1. The Oracle DataAccess Class does not appear in blue for example, OracleConnection, as compare to C#. 2. The intellisense is not as strong when comparing to C# as well.

The following are the few lines of code that in the sample:

static String ^ORA_CONNECTION_STRING = "Data Source=orcldemo;Persist Security Info=True;User ID=HR;Password=hr;";

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {

       OracleConnection ^conn = gcnew OracleConnection(ORA_CONNECTION_STRING);

       conn->Open();

 

       OracleCommand ^cmd = gcnew OracleCommand();

       cmd->Connection = conn;

 

       cmd->CommandText = "select department_id, department_name, city"

                + " from departments d, locations l" + " where d.location_id =

                   l.location_id";

 

        OracleDataReader ^dr = cmd->ExecuteReader();

 

       while (dr->Read())

       {

         listBox1->Items->Add("The " + dr->GetString(1) +

                           " department is in " + dr->GetString(2));

       }

 

       conn->Close();      

     }

 

Download the sample file from http://skydrive.live.com. The sample file name is WinAppCpp.zip. My MSN ID is chanmmn@hotmail.com

Comments (1)

Raghav:

Hi,

I'm developing a COM in VC++.NET that will connect to Oracle. I couldn't find any other example that will help. Can pl forward me this code? It will be of great help!

Thanks

Raghav

Post a comment

About This Entry

This page contains a single entry from the blog posted on September 17, 2008 6:58 PM.

The previous post in this blog was Build a Web Application with JDeveloper 10g Using EJB, JPA, and JavaServer Faces (end product).

The next post in this blog is Using ADF Business Components with Oracle ADF (end product).

Many more can be found on the main index page or by looking through the archives.

Top Tags

Powered by
Movable Type and Oracle