Click here to Skip to main content
14,984,183 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this error appear here

C#
this.je_users_pendsTableAdapter.Fill(this.je_goDataSet.je_users_pends);


during inserting new row i use datetime.now to get the current date
value of date in the mysql database : (0000-00-00)

connection string :

C#
//connectios
      public static string server = "localhost";
      public static string database = "jedb";
      public static string uid = "root";
      public static string password = "";

      public static string OPTION = "Convert Zero Datetime=True";

      public static string JGM_connStr = "SERVER=" + server + ";" + "DATABASE=" +
      database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";" + OPTION + ";";



an idea ?
Posted

If you're having 00-00-0000 date value stored, (Which is special zero value[^]; or you can say DateTime's NULL value), then you should know that .NET framework's DateTime object has a limitation over the DateTime value too, this might be the reason for your errors. No matter whether you convert the data to a proper format while extracting the values from MySQL, you still have to make sure that data is valid according to .NET framework's validation rules.

Quote:
The DateTime value type represents dates and times with values ranging from 00:00:00 (midnight), January 1, 0001 Anno Domini (Common Era) through 11:59:59 P.M., December 31, 9999 A.D. (C.E.) in the Gregorian calendar.


MSDN has resources[^] for that.
   
v2
Comments
Golden Basim 9-Apr-15 9:36am
   
what i should to do to solve this problem ?
Afzaal Ahmad Zeeshan 9-Apr-15 9:37am
   
You could pass your own value (that will suit the standards of .NET framework) if the value from the database is (00-00-0000).
Golden Basim 9-Apr-15 11:46am
   
i changed custom format of date time picker to : yyyy-MM-dd , but no changes , please give me sample .. i use vs 2010
Afzaal Ahmad Zeeshan 9-Apr-15 11:48am
   
The format of the DateTime is not a problem. You need to make sure that valid date time is entered; or at least the date time value is of .NET framework's standards.
Golden Basim 9-Apr-15 12:08pm
   
how i know the date time value of .NET framework's standards.
Afzaal Ahmad Zeeshan 9-Apr-15 12:11pm
   
Read the MSDN document that I have attached in my answer. :)
C#
DateTime rewardes_date = rewardes_dateDateTimePicker.Value.Date;
   

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




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900