?
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,371 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
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
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…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

830 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