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)
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
Posted by Raghav | October 21, 2008 4:34 AM
Posted on October 21, 2008 04:34