Solved

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

Posted on 2004-09-09
5
1,335 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 40 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 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