Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42220

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

$
0
0
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


Viewing all articles
Browse latest Browse all 42220

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>