开发者

ODP.NET VB.Net calling a stored procedure and returning a refCursor

This problem has driven me mad for over a day now. I can create a connection to the database, I can execute sql and return results from that but I can't seem to call a stored Procedure. Here is the code

    Dim myCMD As New OracleCommand
    Dim TheDataReader as New OracleDataReader

    myConnection1.Open()

    myCMD.Connection = myConnection1
    myCMD.CommandType = CommandType.StoredProcedure
    myCMD.CommandText = "WS_DAT开发者_运维技巧A_LAYER.select_user_groups"

    myCMD.Parameters.Add(New OracleParameter("id_user", OracleDbType.VarChar2)).Value = "TXA"
    myCMD.Parameters.Add(New OracleParameter("ws_rs", OracleDbType.RefCursor)).Direction = ParameterDirection.Output

    ' Tried every single execute function here and none have worked
    ' Either error is thrown or empty refcursor
    myCMD.ExecuteScalar()

    TheDataReader = myCMD.Parameters(1).Value().GetDataReader()

The Problem lies in ExecuteScalar at the moment. It's throwing an exception called "Input string was not in a correct format". I've tried passing the string with Oracle single quotes and get the same thing. If I use

    TheDataReader = myCMD.ExecuteQuery()

it works ok but no results are returned. I've verified that the procedure returns results for the user I'm logged in as. When the query was executing I could see a refcursor in there but it was empty. I must be going mad.

Any help is appreciated


Anyone else that may have this problem, I was passing the OracleDBType.Varchar2 as a parameter to the above VB method. But I had it declared as an integer, it needs to be explicitly passed as an OracleDBType

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜