?
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,367 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

649 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