首页 > 解决方案 > ORA-01858: 在需要数字的地方发现了一个非数字字符 - VB.NET

问题描述

我正在尝试构建一个用于查询 Oracle 数据库的 SQL 语句,并有两个参数作为日期类型。

cmd.Parameters.Add(New OracleParameter(":pCommencementDate", OracleDbType.Date)).Value = comm.OraFormatDate(txtCommenceDate.Text)
cmd.Parameters.Add(New OracleParameter(":pCompletionDate", OracleDbType.Date)).Value = comm.OraFormatDate(txtCompleteDate.Text)

Public Function OraFormatDate(ByVal strDate As String) As String
    Try
        Dim a As Date
        SetGlobalDay()
        a = Format(CDate(strDate), "dd/MM/yyyy")
        Return "to_date('" & a & "','dd/mm/yyyy')"
    Catch ex As Exception
        ERR.sWriteErrorLog("C:\", "(common OraFormatDate) -> " & ex.Message)
    End Try

End Function

构建查询并尝试执行后,我得到 ORA-01858 错误。

标签: vb.netoracle

解决方案


推荐阅读