如何将Oracle参数值存储到数组列表中 [英] How to store oracle parameter values into array list

查看:353
本文介绍了如何将Oracle参数值存储到数组列表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了以下编码:

I had Tried the following coding:

 ArrayList obj = new ArrayList();
          insert_pro insobj= new insert_pro();
           OracleCommand cmd = new OracleCommand("ins1", conn);
           cmd.CommandType = CommandType.StoredProcedure;
           OracleParameter emp_obj = new OracleParameter();
        for (int i = 0; i < arr_id.Count; i++)
          {

            insobj._Id = Convert.ToInt16(arr_id[i].ToString());
            insobj._Name = arr_name[i].ToString();
            insobj._Gender= arr_gender[i].ToString();
 emp_obj.OracleDbType = OracleDbType.Object;
            emp_obj.Direction = ParameterDirection.Input;
            emp_obj.Size = arr_len;
            emp_obj.UdtTypeName = "SMP_EMP_TYPE";
            emp_obj.Value = insobj;
              obj.Add(emp_obj);
}


这里能够将参数值存储到数组列表中,但是它将最后一个 emp_obj.value 存储到所有参数中.....


here am able to store parameters values into array list but it stores the last emp_obj.value to all parameters....

推荐答案


在循环中移动此行.实际上,您是在覆盖值,而不是创建新值.这就是为什么您要获得所有参数的最后一个值的原因.
Hi
Move this line inside the loop. Actually you are overwriting the values, not creating new one. Thats why you are getting last value for all parameters.

insert_pro insobj= new insert_pro();


这篇关于如何将Oracle参数值存储到数组列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆