private void InsertExample()
{
try
{
string strConn = "User ID=ims;Data Source=dev;Password=getup";
// OleDbConnection myConn = new OleDbConnection ( strConn ) ;
OracleConnection myConn = new OracleConnection(strConn);
myConn.Open();
string sql = " INSERT INTO ims.delivery ( SHIPMNT_NO , INPUT_PN , INPUT_DT ) VALUES (:SHIPMNT_NO,:INPUT_PN,:INPUT_DT) ";
OracleParameter shipmntnoPara = new OracleParameter(":SHIPMNT_NO", OracleType.VarChar, 15, "SHIPMNT_NO");
OracleParameter inputPnPara = new OracleParameter(":INPUT_PN", OracleType.VarChar, 20, "INPUT_PN");
OracleParameter inputdtPara = new OracleParameter(":INPUT_DT", OracleType.DateTime, 20, "INPUT_DT");
OracleCommand oleDbCommand1 = new OracleCommand(sql, myConn);
// OracleDataAdapter oracleDataAdapter = new OracleDataAdapter
oleDbCommand1.CommandText = sql;
shipmntnoPara.Value = "PKNI20100101";
inputPnPara.Value = "cs@@lcsl'''%";
inputdtPara.Value = System.DateTime.Now;
oleDbCommand1.Parameters.Add(shipmntnoPara);
oleDbCommand1.Parameters.Add(inputdtPara);
oleDbCommand1.Parameters.Add(inputPnPara);
oleDbCommand1.CommandType = CommandType.Text;
//oleDbCommand1.CommandType = CommandType.StoredProcedure;
oleDbCommand1.ExecuteNonQuery();
myConn.Close();
//---------------------------------------------------------------------------------------
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
/// <summary>
/// 返回DataSet
/// </summary>
/// <returns></returns>
public DataSet GetQueryDataSetExamples()
{
try
{
string strconn = "User ID=ims;Data Source=dev;Password=getup";
string sql="select * from ims.delivery where shipmnt_no=:shipmnt_no";
OracleConnection oracleConnection = new OracleConnection(strconn);
oracleConnection.Open();
OracleDataAdapter oracleDataAdapter = new OracleDataAdapter(sql, strconn);
OracleParameter shipmntNoPara = new OracleParameter(":shipmnt_no", OracleType.VarChar, 15, "shipmnt_no");
shipmntNoPara.Value = "PKNI20080012";
oracleDataAdapter.SelectCommand.Parameters.Add(shipmntNoPara);
DataSet set=new DataSet();
oracleDataAdapter.Fill(set);
oracleConnection.Close();
return set;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
/// <summary>
/// 返回DataSet
/// </summary>
/// <returns></returns>
public int UpdateExamples()
{
try
{
string strconn = "User ID=ims;Data Source=dev;Password=getup";
string sql = "update ims.delivery set shipmnt_no=:shipmnt_no1 where shipmnt_no=:shipmnt_no2";
OracleConnection oracleConnection = new OracleConnection(strconn);
oracleConnection.Open();
// OracleDataAdapter oracleDataAdapter = new OracleDataAdapter(sql, strconn);
OracleCommand oracleCommand = new OracleCommand(sql, oracleConnection);
OracleParameter shipmntNo1 = new OracleParameter(":shipmnt_no1", OracleType.VarChar, 15, "shipmnt_no");
OracleParameter shipmntNoPara = new OracleParameter(":shipmnt_no2", OracleType.VarChar, 15, "shipmnt_no");
shipmntNo1.Value = "PKNI20101201";
shipmntNoPara.Value = "PKNI20080012";
oracleCommand.Parameters.Add(shipmntNoPara);
oracleCommand.Parameters.Add(shipmntNo1);
int i = oracleCommand.ExecuteNonQuery();
oracleConnection.Close();
return i;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}