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,453 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
[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
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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