Link to home
Start Free TrialLog in
Avatar of alsam
alsam

asked on

Query against Oracle database - parameter

Hi,
when I execute vb code below I receive error message "Ora - 01843: Not a Valid Month"
Please help me to solve the problem..what did I make wrong...
Query is executed against Oracle Database....
Thank you....
Dim cmd1 As New System.Data.OleDb.OleDbCommand
        cmd1.Connection = conn1
        cmd1.CommandType = CommandType.Text
        cmd1.CommandText = "select ACCOUNT_ID from my_table where full_date >= to_date(:datum_val1, 'dd.mm.yyyy') AND full_date <= to_date(:datum_val2, 'dd.mm.yyyy')"
        cmd1.CommandTimeout = 0
cmd1.Parameters.Add(":datum_val1", OleDbType.VarChar)
        cmd1.Parameters(":datum_val1").Value = Me.DateTimePicker1.Value.ToString("dd.mm.yyyy")
        cmd1.Parameters.Add(":datum_val2", OleDbType.VarChar)
        cmd1.Parameters(":datum_val2").Value = Me.DateTimePicker2.Value.ToString("dd.mm.yyyy")
        Dim rdr As OleDbDataReader = cmd1.ExecuteReader

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ronythom
ronythom

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of alsam
alsam

ASKER

Ok I found wghere the problem was. I had to change Me.DateTimePicker2.Value.ToString
into Me.DateTimePicker2.Text and it works OK...
Also, :datum_val should be changed in ? in statement....
Anyway thank you for your time and effort...