Question : 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.
Code Snippet:
1:
2:
3:
4:
if (dtDOB.Text.Length > 0)
            {
                myProviderReferralQueue.LabResultDate = Convert.ToDateTime(dtLabResult.Text);----Error Here---<
            }

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

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.
Random Solutions  
 
programming4us programming4us