Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help using C# application to connect to oracle database

694384Apr 2 2009 — edited Apr 11 2009
I'm new to database.

I'm developing a C# GUI application in visual studio 2008 that is suppose to interact with oracle. After researching and trying out several sample codes, nothing works and I'm in desperate need of some help/advice/suggestions.

The simplest example I'm trying is to just get a button to run a simple SQL query. The code is:
private void button1_Click(object sender, EventArgs e)
{
string oradb = "Data Source=acme.gatech.edu;User Id=gtg880f;Password=******;";
OracleConnection conn = new OracleConnection(oradb); // C#
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = "select Location_Name from warehouse where Location_name = 'atlanta'";
cmd.CommandType = CommandType.Text;
OracleDataReader dr = cmd.ExecuteReader();
dr.Read();
label1.Text = dr.GetString(0);
conn.Dispose();
}

I've installed many many version of oracle database and have included the Oracle.Data.Access under reference.

If I use putty and connect to acme.gatech.edu via port 22, I can type sqlplus / and run the query "elect Location_Name from warehouse where Location_name = 'atlanta'" and it'll work.

After some research, some say that if I can connect via sqlplus that means i can connect to the database but what do i need to implement to enable my c# code in visual studio to be able to do that.

I did a search on the forum but found nothing that matches this. In essence, I'm not sure what/how to specify such that I can connect to the acme.gatech.edu server and run sql commands.

Thanks,

Oky Sabeni
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 9 2009
Added on Apr 2 2009
5 comments
7,936 views