Solved

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

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

16 Experts available now in Live!

Get 1:1 Help Now