获取ORA-22054下溢错误和ORA-22053溢出错误

时间:2016-12-27 02:59:29

标签: .net vb.net oracle

ORA-22054 underflow error

此示例使用Visual Studio 2013和Oracle.DataAccess.dll
因为oracle参数会出现问题。您必须将参数设置为数组。

Dim sql As String
Dim dt As DataTable
Dim da As OracleDataAdapter
Dim cmd As OracleCommand
Dim params(3) As OracleParameter

Using conn As New OracleConnection(OracleConnString)
    sql = "select col1, col2, col3, col4, col5 from table1 " & _
          "where col1 like '%'||:pValue1||'%' and col2 = :pValues2 " & _
          "and col3 = :pValue3 and col4 = :pValue4"
    conn.Open()

    params(0) = New OracleParameter(":pValue1", OracleDbType.Varchar2, vValue1, ParameterDirection.Input)
    params(1) = New OracleParameter(":pValue2", OracleDbType.Int32, vValue2, ParameterDirection.Input)
    params(2) = New OracleParameter(":pValue3", OracleDbType.Varchar2, vValue3, ParameterDirection.Input)
    params(3) = New OracleParameter(":pValue4", OracleDbType.Date, vValue4, ParameterDirection.Input)

    cmd = New OracleCommand(sql, conn)
    If Not Paramaters Is Nothing Then
        For i As Integer = 0 To params.Length - 1
            cmd.Parameters.Add(Paramaters(i))
        Next
    End If

    dt = New DataTable
    da = New OracleDataAdapter(cmd)
    da.Fill(dt)
    da.Dispose()
    conn.Close()
End Using

0 个答案:

没有答案