2 Replies Latest reply: Sep 4, 2012 6:38 AM by Tridus RSS

    Error in Inserting the Date + ORACLE

    944059
      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('18/07/2011','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 I run the Code I get the ERROR message
      a non-numeric character was found where a numeric character was expected.

      ORACLE TABLE : -
      Create table practise2(dob date)