?
Solved

The string was not recognized as a valid DateTime when I call the Stored Procedure

Posted on 2004-09-09
5
Medium Priority
?
1,358 Views
Last Modified: 2012-06-21
Hi

I'm getting this error when I execute the stored procedure from my VB.NET Programme. What is the mistake I'm doing:

ERROR:
The string was not recognized as a valid DateTime. There is a unknown word starting at index 0


This is the code I have:

 myCMD.Parameters.Add(New OracleParameter("i_start_dt_gmt", OracleType.DateTime)).Value = "TO_DATE('& strdate &',DD-MON-YYYY HH:MM:SS AM/PM)"
        myCMD.Parameters.Add(New OracleParameter("i_end_dt_gmt", OracleType.DateTime)).Value = "TO_DATE('& strdate1 &',DD-MON-YYYY HH:MM:SS AM/PM)"
       
myCMD.ExecuteNonQuery()

 Try
            MyDA.Fill(Ds)
        Catch x
            MessageBox.Show(x.Message.ToString)
        End Try

I'M CALLING AN ORACLE STORED PROCEDURE. ANY HELP PLEASE.

Thanks
vm
0
Comment
Question by:vmandem
[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
5 Comments
 
LVL 8

Expert Comment

by:razo
ID: 12016316
myCMD.Parameters.Add(New OracleParameter("i_start_dt_gmt", OracleType.DateTime)).Value = TO_DATE('& strdate &',DD-MON-YYYY HH:MM:SS AM/PM)
0
 

Author Comment

by:vmandem
ID: 12016544
razo

I tried it but still get the same error message.
When I went and looked at the stored procedure the datatype is declared as Date. I cannot modify the stored procedure but I have to handle it on my vb.net app.
Here when I say OracleType. ,I GET ONLY DateTime as option but not DATE, do you think is that the reason it is causing it.

I appreciate your response.

Thanks
vm
0
 

Author Comment

by:vmandem
ID: 12016627
razo
I did not observer at that time but when I looke at your code you removed the quotes befor TO_DATE and after the end of string.
If I do that it turns to green and I cannot assign the value to the string on left side.

Thanks
vm
0
 
LVL 7

Accepted Solution

by:
natloz earned 160 total points
ID: 12017388
myCMD.Parameters.Add(New OracleParameter("i_start_dt_gmt", OracleType.DateTime)).Value = CDate(strdate)
0
 
LVL 1

Expert Comment

by:iamtgo3
ID: 12019339
TO_DATE('" & strdate & "',DD-MON-YYYY HH:MM:SS AM/PM)"

One thing I believe you are missing " before and after the &.


George - www.ipdg3.com
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

765 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