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

About these ads

About chanmingman

Ming Man is a senior manager for a development company. With 20 years of experience in the IT field, he has developed system using Clipper, COBOL, VB5, VB6, VB.NET, Java and C #. He is familiar with the N-Tier design of business application and is also an expert with database experience in MS SQL, Oracle and AS 400.
This entry was posted in .Net. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s