【发布时间】:2018-05-15 10:36:15
【问题描述】:
我是 oracle 的新手,正在使用过程并且仍在学习,但是我有一个问题,如何使用存储过程填充组合框?我已经有一个代码,但是当我运行它时,它显示错误 IndexOutOfRangedException is unhandled and Cannot find Column 1.
这是我的代码 (程序/Oracle Sql:)
procedure cmbbox_location (o_output out o_refcur)
as
o_cur o_refcur;
begin
open o_cur for
select city_id, city_name from city;
o_output := o_cur;
end cmbbox_location;
(程序/vb.net)
Private Sub Main_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
instantiate_dev()
ora_conn.Open()
populate_cmbbox_loc()
End Sub
Private Sub populate_cmbbox_loc()
instantiate_dev()
ora_conn.Open()
qr.populate_location()
cmblocation.DataSource = dt
cmblocation.ValueMember = dt.Columns(0).ColumnName
cmblocation.DisplayMember = dt.Columns(1).ColumnName
cmblocation.Text = ""
cmblocation.SelectedIndex = 0
End Sub
Public Function populate_location()
dt = New DataTable
bg.GetProcDataTable(connStr, "Location_Package.cmbbox_location")
cmd.Parameters.Add(New OracleParameter("O_OUTPUT", OracleDbType.RefCursor)).Direction = ParameterDirection.Output
adap_or.SelectCommand = cmd
adap_or.Fill(dt)
Return dt
ora_conn.Close()
End Function
【问题讨论】:
-
我不知道vb.net,但
o_output out o_refcur不应该是o_output out sys_refcursor吗?o_refcur听起来不像一个类型,它听起来像一个OUT参数。另外你不需要o_cur,你可以直接打开o_output。 -
您使用的是 Oracle 客户端还是其他提供商?