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 sqlUpdate = "update PlayerTable ";
sqlUpdate += "set last_name = :p_last, ";
sqlUpdate += "first_name = :p_first, ";
sqlUpdate += "position = :p_pos, ";
sqlUpdate += "club = :p_club " ;
sqlUpdate += "where player_num = :p_num";
OracleCommand cmdUpdate = new OracleCommand();
cmdUpdate.CommandText = sqlUpdate;
cmdUpdate.Connection = oraConn;
OracleParameter pPlayerNum = new OracleParameter();
pPlayerNum.DbType = DbType.Decimal;
pPlayerNum.Value = 10;
pPlayerNum.ParameterName = "p_num";
OracleParameter pLastName = new OracleParameter();
pLastName.Value = "Tom";
pLastName.ParameterName = "p_last";
OracleParameter pFirstName = new OracleParameter();
pFirstName.Value = "Gib";
pFirstName.ParameterName = "p_first";
OracleParameter pPosition = new OracleParameter();
pPosition.Value = "a";
pPosition.ParameterName = "p_pos";
OracleParameter pClub = new OracleParameter();
pClub.Value = "abc";
pClub.ParameterName = "p_club";
cmdUpdate.Parameters.Add(pLastName);
cmdUpdate.Parameters.Add(pFirstName);
cmdUpdate.Parameters.Add(pPosition);
cmdUpdate.Parameters.Add(pClub);
cmdUpdate.Parameters.Add(pPlayerNum);
cmdUpdate.ExecuteNonQuery();
MessageBox.Show("Record Updated Successfully" , "Record Updated");
cmdUpdate.Dispose();
}
}
}