public partial class Form1 : Form
{
private OracleConnection con; //创建连接对象
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
if (con == null) //判断连接对象是否为空
{
con = new OracleConnection("User Id=SJ;Password=DONTZ1110;Data Source=roxlinclient;"); //创建数据库连接对象
}
if (con.State == ConnectionState.Closed) //判断数据库连接是否关闭
con.Open(); //打开数据库连接
}
catch (Exception ex)
{
MessageBox.Show( "Open DB Erro:" + ex.Message);
}
}
private void button1_Click(object sender, EventArgs e)
{
OracleCommand cmd = new OracleCommand("SAJET.SJ_WO_MATERIAL4", con);
cmd.CommandType = CommandType.StoredProcedure;
OracleParameter param1 = new OracleParameter("TWO", OracleType.VarChar, 30);
param1.Direction = ParameterDirection.Input;
param1.Value="TEST";
cmd.Parameters.Add(param1);
OracleParameter param2 = new OracleParameter("TKPNO", OracleType.VarChar, 30);
param2.Direction = ParameterDirection.Input;
param2.Value = "63147020002-HC2";
cmd.Parameters.Add(param2);
OracleParameter param3 = new OracleParameter("TDATECODE", OracleType.VarChar, 30);
param3.Direction = ParameterDirection.Input;
param3.Value = "20131120";
cmd.Parameters.Add(param3);
OracleParameter param4 = new OracleParameter("TREELNO", OracleType.VarChar, 30);
param4.Direction = ParameterDirection.Input;
param4.Value = "A00008975698";
cmd.Parameters.Add(param4);
OracleParameter param5 = new OracleParameter("TPDLINEID", OracleType.VarChar, 30);
param5.Direction = ParameterDirection.Input;
param5.Value = "20092";
cmd.Parameters.Add(param5);
OracleParameter param6 = new OracleParameter("TPROCESSID", OracleType.VarChar, 30);
param6.Direction = ParameterDirection.Input;
param6.Value = "200007";
cmd.Parameters.Add(param6);
OracleParameter param7 = new OracleParameter("TEMPID", OracleType.VarChar, 30);
param7.Direction = ParameterDirection.Input;
param7.Value = "20001511";
cmd.Parameters.Add(param7);
OracleParameter param8 = new OracleParameter("TVENDOR", OracleType.VarChar, 30);
param8.Direction = ParameterDirection.Input;
param8.Value = "0001848U";
cmd.Parameters.Add(param8);
OracleParameter param9 = new OracleParameter("TQTY", OracleType.VarChar, 30);
param9.Direction = ParameterDirection.Input;
param9.Value = "900";
cmd.Parameters.Add(param9);
OracleParameter param10 = new OracleParameter("TRES", OracleType.VarChar,100);
param10.Direction = ParameterDirection.Output;
cmd.Parameters.Add(param10);
cmd.ExecuteNonQuery();
String res = cmd.Parameters[9].Value.ToString();
MessageBox.Show(res);
}
}
------解决思路----------------------
贴上过程SAJET.SJ_WO_MATERIAL4
------解决思路----------------------
过程太长了,不好看,建议你在过程加一个返回参:prm_OUTRESULT OUT sys_refcursor
通过open prm_OUTRESULT for select ……的方式调试