VB.NET调用存储过程(Oracle),传参数问题,谢谢大家。
CREATE OR REPLACE PROCEDURE EXE_TEST is
ACHAR(8);
BTEST_TBL.D;
CNUMBER(1);
BEGIN
DBMS_OUTPUT.ENABLE;
A := '12345678';
B(1) := '100001';
B(2) := '100002';
TEST(A,B,C);
END ;
/
CREATE OR REPLACE PACKAGE TEST_TBL is
TYPE D IS TABLE OF CHAR(6) INDEX BY BINARY_INTEGER;
END;
/
CREATE OR REPLACE PROCEDURE TEST(A IN CHAR, B IN TEST_TBL.D, C OUT NUMBER) is
========================================================================
现在想在VB里提调用Test这个存储过程,
Dim dbConn As New OleDbConnection
Dim dbComm As OleDbCommand
dbConn.ConnectionString = "Provider=MSDAORA.1;User ID=XXX;Password=XXX;Data Source=XXX;"
dbConn.Open()
dbComm = dbConn.CreateCommand
dbComm.Parameters.Add("A", OleDbType.VarChar, 8).Direction = ParameterDirection.Input
dbComm.Parameters.Add("B", OleDbType.VarBinary).Direction = ParameterDirection.Input
dbComm.Parameters.Add("C", OleDbType.Double, 1).Direction = ParameterDirection.Output
dbComm.Parameters("A").Value = "12345678"
dbComm.Parameters("C").Value = 0
Dim a(0 To 5) As Byte
a(0) = "100001"
a(1) = "100002"
dbComm.Parameters("B").Value = a
dbComm.CommandText = "{CALL TEST(?,?,?)}"
dbComm.CommandType = CommandType.Text
dbComm.ExecuteNonQuery()
dbConn.Close()
请大家帮忙看看,VB里传参数哪里写的不对,谢谢了
[解决办法]
dbComm.Parameters.Add("A", OleDbType.VarChar, 8).Direction = ParameterDirection.Input
dbComm.Parameters.Add("B", OleDbType.VarBinary).Direction = ParameterDirection.Input
dbComm.Parameters.Add("C", OleDbType.Double, 1).Direction = ParameterDirection.Output
A,B是输入,那为什么要给C赋值?
dbComm.Parameters("C").Value = 0
[解决办法]
C不是输出参数么,为什么要赋值?
我的异常网推荐解决方案:oracle存储过程,http://www.myexception.cn/oracle-develop/177537.html