using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OracleClient;
public class MainClass
{
public static void Main()
{
OracleConnection oraConn = new OracleConnection();
string connString = "User Id=oranetuser; Password=demo; Data Source=oranet";
if (oraConn.State != ConnectionState.Open)
{
try
{
oraConn.ConnectionString = connString;
oraConn.Open();
MessageBox.Show(oraConn.ConnectionString, "Successful Connection");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message,"Exception Caught");
}
}
if (oraConn.State == ConnectionState.Open)
{
string sqlLookup = "select last_name, first_name, from PlayerTable ";
sqlLookup += "where player_num = :player_num";
OracleCommand cmdLookup = new OracleCommand();
cmdLookup.CommandText = sqlLookup;
cmdLookup.Connection = oraConn;
OracleParameter pPlayerNum = new OracleParameter();
pPlayerNum.DbType = DbType.Decimal;
pPlayerNum.Value = 10;
pPlayerNum.ParameterName = "player_num";
cmdLookup.Parameters.Add(pPlayerNum);
OracleDataReader dataReader = cmdLookup.ExecuteReader();
if (dataReader.Read()){
Console.WriteLine(dataReader.GetString(0));
Console.WriteLine(dataReader.GetString(1));
Console.WriteLine(dataReader.GetString(2));
Console.WriteLine(dataReader.GetString(3));
}else{
MessageBox.Show("No record for Player Number Found" , "No Record Found");
}
dataReader.Close();
dataReader.Dispose();
cmdLookup.Dispose();
}
}
}