将OracleDbType.Date转换为Date无效

问题描述 投票:2回答:1

我正在尝试从OracleCommand.Parameter执行以下操作:

存储过程:

PROCEDURE GetDate(inParam IN VARCHAR2, outDate OUT DATE) AS
    BEGIN
        SELECT MAX(DateVal) INTO outDate
        FROM Table1
        WHERE Col1 = inParam;
    EXCEPTION 
        WHEN no_data_found THEN
        outDate:= NULL;
END GetDate;
Dim returnDate as Date?

Using Connection = New OracleConnection(connectionString)
Using Command As OracleCommand = Connection.CreateCommand()

Connection.Open()
Command.CommandType = CommandType.StoredProcedure
Command.CommandText = "GEN_PACKAGE.GetDate"
Command.Parameters.Add("inParam", inParam).Direction = ParameterDirection.Input
Command.Parameters.Add("outDate", OracleDbType.Date).Direction = ParameterDirection.Output
Command.ExecuteNonQuery()

If Not CType(Command.Parameters("outDate").Value, INullable).IsNull Then
    returnDate = CDate(Command.Parameters("outDate").Value)
End If

End Using
End Using

但是会引发以下异常:

抛出异常:Microsoft.VisualBasic.dll中的'System.InvalidCastException'其他信息:从“ OracleDate”类型到“ Date”类型的转换无效。

如果OracleDbType.Date无法转换为.NET Date类型,那有什么意义?我怎样才能将OracleDbType.Date并以.NET Date的形式(或日期?,我都尝试过)传递给我?

我正在尝试从OracleCommand.Parameter执行以下操作:存储过程:PROCEDURE GetDate(inParam IN VARCHAR2,outDate OUT DATE)作为开始SELECT MAX(DateVal)INTO outDate ...

vb.net oracle odp.net
1个回答
0
投票
好,所以这是这里最大的误解(我经常从ODP用法中看到)
© www.soinside.com 2019 - 2024. All rights reserved.