Solved

Query against Oracle database - parameter

Posted on 2010-09-15
2
260 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
2 Comments
 
LVL 1

Accepted Solution

by:
ronythom earned 500 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

813 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now