Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1547
  • Last Modified:

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

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
kwh3856
Asked:
kwh3856
1 Solution
 
tcullerCommented:
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
 
kwh3856Author Commented:
That did it for me.  
System.DateTime.Parse

Thanks
Kenny
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now