C# 連接Oracle數據庫Procedures
private string connectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=XX.XX.XX.XX)(PORT=???))(CONNECT_DATA=(SERVICE_NAME=XXX)));User Id=XXX;Password=XXX";
//ProName:調用的Procedure名
private void ExecuteSql(string ProName, string sP1, string sP2, string sP3 )
{
using (OracleConnection connection = new OracleConnection(connectionString))
{
connection.Open();
OracleCommand cmd = new OracleCommand(ProName, connection);
OracleParameter[] paras = {
new OracleParameter("Cond_P1",OracleDbType.Varchar2,sP1,ParameterDirection.Input),
new OracleParameter("Cond_P2",OracleDbType.Int32,sP2,ParameterDirection.Input),
new OracleParameter("Cond_P3",OracleDbType.Clob, sP3,ParameterDirection.Input),
};
cmd.Parameters.AddRange(paras);
try
{
cmd.CommandType = CommandType.StoredProcedure;//设置 使用存储过程
cmd.ExecuteNonQuery();
}
catch (OracleException E)
{
}
finally
{
cmd.Dispose();
connection.Close();
}
}
}