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 sqlInsert = "insert into PlayerTable (player_num, last_name, first_name, position, club) ";
sqlInsert += "values (:p_num, :p_last, :p_first, :p_pos, :p_club)";
OracleCommand cmdInsert = new OracleCommand();
cmdInsert.CommandText = sqlInsert;
cmdInsert.Connection = oraConn;
OracleParameter pPlayerNum = new OracleParameter();
pPlayerNum.DbType = DbType.Decimal;
pPlayerNum.Value = 10;
pPlayerNum.ParameterName = "p_num";
OracleParameter pLastName = new OracleParameter();
pLastName.Value = "Last";
pLastName.ParameterName = "p_last";
OracleParameter pFirstName = new OracleParameter();
pFirstName.Value = "FirstName";
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";
cmdInsert.Parameters.Add(pPlayerNum);
cmdInsert.Parameters.Add(pLastName);
cmdInsert.Parameters.Add(pFirstName);
cmdInsert.Parameters.Add(pPosition);
cmdInsert.Parameters.Add(pClub);
cmdInsert.ExecuteNonQuery();
cmdInsert.Dispose();
}
}
}
|