Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
1,508 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 2000 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

Basic Security of Your VPC

So, you’ve got this shiny new VPC and a fancy new application configured on your EC2 servers ready to go. This application is only accessible from your computer, which is great for security, but you need your users to be able to access it! So, what’s the easiest way to do this?

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.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

660 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