[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Query against Oracle database - parameter

Posted on 2010-09-15
2
Medium Priority
?
265 Views
Last Modified: 2012-08-13
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

0
Comment
Question by:alsam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
ronythom earned 1500 total points
ID: 33685913
what is the value on datum_val1 and datum_val2. Is it included the ".", if not it cause the problem

to_date('01.03.1990','DD.MM.YYYY') then no prpblem

to_date('01031990','DD.MM.YYYY') it will return error
0
 
LVL 1

Author Closing Comment

by:alsam
ID: 33688998
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...
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question