Skip to content

Instantly share code, notes, and snippets.

@cx20
Created June 10, 2012 14:28
Show Gist options
  • Save cx20/2905916 to your computer and use it in GitHub Desktop.
Save cx20/2905916 to your computer and use it in GitHub Desktop.
Hello, ODP.NET World! (C# + ODP.NET + Oracle)
using System;
using Oracle.DataAccess.Client;
class Hello
{
static void Main( String[] args )
{
string conStr = "Data Source=;"
+ "User Id=scott;"
+ "Password=tiger";
string sqlStr = "SELECT 'Hello, ODP.NET World!' AS Message FROM DUAL";
OracleConnection con = new OracleConnection(conStr);
OracleCommand cmd = new OracleCommand(sqlStr, con);
con.Open();
OracleDataReader reader = cmd.ExecuteReader();
while( reader.Read() )
{
Console.WriteLine( reader.GetName(0) );
Console.WriteLine( "---------------------" );
Console.WriteLine( reader[0] );
}
reader.Close();
con.Close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment