Click here to Skip to main content
12,395,117 members (60,283 online)
Rate this:
Please Sign up or sign in to vote.
See more: SQL-Server
hi all,
please tellme any one . when i write like this textbox1.text = or system.datetime.utcnow. i will get error like.SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
Posted 11-Oct-12 4:17am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Difficult to be sure with that little info, but the most likely reason is that the PC is set to a locale where the date format is confusing SQL when you try to add it to the database as a string.

Instead, convert the TextBox.Text property to a DateTime value using the Parse or TryParse methods, and pass the DateTime itself to SQL as a parameter instead. You should not be passing TextBox contents to SQL directly anyway - it is a recipe for SQL Injection Attacks which can damage or destroy your database. Always use Parametrized queries to avoid this, and your Date problems will disappear as well.
Maciej Los 11-Oct-12 13:32pm
Good answer, my 5!
Marcus Kramer 11-Oct-12 15:17pm
damodara naidu betha 12-Oct-12 2:18am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 11 Oct 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100