Solved

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

Posted on 2009-05-09
2
1,442 Views
Last Modified: 2013-12-17
I am trying to determine if the user keyed data into a date field, if they do I then capture the data to a variable and save it to the table.  I keep getting this error message I do not know what it means.  Can someone help me out with this error?

The LabResultDate is a datetime field in a SQL 2005 database.
if (dtDOB.Text.Length > 0)
            {
                myProviderReferralQueue.LabResultDate = Convert.ToDateTime(dtLabResult.Text);----Error Here---<
            }

Open in new window

0
Comment
Question by:kwh3856
2 Comments
 
LVL 9

Accepted Solution

by:
tculler earned 500 total points
ID: 24346555
Can you give an example of what you've tried entering already? Also, have you thought about using a System.Windows.Forms.DateTimePicker instead of a TextBox? This would probably be more ideal, and easier on you ;)

If you'd rather not use a DateTimePicker, try System.DateTime.Parse and TryParse, let me know what happens, and we'll go from there.
0
 

Author Closing Comment

by:kwh3856
ID: 31579846
That did it for me.  
System.DateTime.Parse

Thanks
Kenny
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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

807 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