Results 1 to 4 of 4

Thread: A Non-numeric character was found where a numeric was expected + ORACLE

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2008
    Posts
    474

    A Non-numeric character was found where a numeric was expected + ORACLE

    Code:
    Imports System.Globalization
    
    Imports System.Data
    Imports Oracle.DataAccess.Client
    
    Partial Class _Default
        Inherits System.Web.UI.Page
        Dim con As New OracleConnection("Data Source=XE;User Id=user_test;Password=sarvagya;")
        Dim cmd As New OracleCommand
        Dim da As OracleDataAdapter
        Dim ds As DataSet
        Dim query As String
    
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Try
                query = "Insert into Practise2 values(:DOB)"
                cmd = New OracleCommand(query, con)
                Dim formats As String() = {"dd/MM/yyyy", "d/M/yyyy"}
                Dim dt As DateTime
    
    
                    cmd.Parameters.Add(":DOB", "TO_DATE('" & dt.ToString() & "','dd/mm/yyyy')")
                If con.State = ConnectionState.Closed Then
                    con.Open()
                End If
                cmd.ExecuteNonQuery()
            Catch ex As Exception
                MsgBox(ex.Message)
            Finally
                If con.State = ConnectionState.Open Then
                    con.Close()
                End If
            End Try
        End Sub
    End Class
    WHen the line cmd.ExecuteNonQUery() is Execueted, I get the ERROR ...A NON-NUMERIC CHARACTER WAS FOUND WHERE A NUMERIC WAS EXPECTED.


    I have used the DATE DataType in ORACLE. I used the same query as I used in .Net, It is perfectly working with ORACLE..
    Code:
    Create table practise2(dob date)
    
    INSERT Into Practise2 values(to_date('18/07/2011','dd/mm/yyyy'))
    INSERT Into Practise2 values(to_date('18/12/2011','dd/mm/yyyy'))
    select * from practise2
    DOB     
    ---------
    18-JUL-11 
    18-DEC-11
    Last edited by sonia.sardana; Sep 1st, 2012 at 11:18 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width