Created
June 10, 2012 14:28
-
-
Save cx20/2905916 to your computer and use it in GitHub Desktop.
Hello, ODP.NET World! (C# + ODP.NET + Oracle)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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