We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:





28672 May 6,2005 02:28 PM UTC May 6,2005 03:33 PM UTC WinForms 1
Tags: GridControl
Asked On May 6, 2005 02:28 PM UTC

(Sorry, I posted this as a reply to Calendar Cell but it''s really not related to that) I just started getting this message on 5/4/05! I''m not parsing and before this, my program worked just fine. Here''s a posting I put on another site in desparation: Greetings, I don''t know how long ago this conversation took place, but am desperate for help with the same problem. Up until two days ago, my code for inserting a record into a table worked fine. Update still works, but on insert, I am getting this dialog box now: System.FormatException: The string was not recognized as a valid DateTime. There is a unknown word starting at index 0 It''s driving me crazy. Mostly because this has worked fine until now. There are four dates (though I removed TimeStamp to try to fix) and I have tried everything! One important thing to note is that my product is completely in English, having nothing to do with other timezones or anything like that. Anyway, I don''t know if anyone can (or has time to) help. Just thought I''d try and ask. :) Carolyn Here''s some more information: ---------------------------------------------------------------------------- ---- SQL Server Table I''m trying to add records to: (NAME: SystemParameter) 2 SystemParameterID int 4 0 (<----Primary key with identity seed) 0 SystemParameterTypeID int 4 0 0 PersonID int 4 1 0 SystemParameterEffectiveDate datetime 8 0 0 SystemParameterEndDate datetime 8 1 0 SystemParameterValue varchar 255 1 0 LastUpdateDate datetime 8 1 1 LastUpdateUser varchar 255 1 ---------------------------------------------------------------------------- ---- (Stored Proc: InsertSystemParameter) (NOTE: Removed Timestamp which didn''t help) CREATE procedure dbo.InsertSystemParameter ( @SystemParameterID int output, @SystemParameterTypeID int, @PersonID int, @SystemParameterEffectiveDate datetime = null, @SystemParameterEndDate datetime = null, @SystemParameterValue varchar(255) = null, @LastUpdateDate datetime = null, @LastUpdateUser varchar(50) = null /*, @TimeStamp timestamp = null*/ ) as insert into SystemParameter ( SystemParameterTypeID, PersonID, SystemParameterEffectiveDate, SystemParameterEndDate, SystemParameterValue, LastUpdateUser ) values ( @SystemParameterTypeID, @PersonID, @SystemParameterEffectiveDate, @SystemParameterEndDate, @SystemParameterValue, @LastUpdateUser ) select @SystemParameterID = @@Identity GO ---------------------------------------------------------------------------- ---- (CODE - You can see where I commented out almost everything I tried!) private void SaveSystemParameter( int systemParameterID, int systemParameterTypeID, int personID, //System.DateTime systemParameterEffectiveDate, //System.DateTime systemParameterEndDate, string systemParameterEffectiveDate, string systemParameterEndDate, string systemParameterValue, string lastUpdateUser, DsSystemParameter dsSystemParameter) { DsSystemParameter.SystemParameterRow systemParameterRow; //-//bool staffingGuideTypeProductivityFlag = false; //-//BcStaffingGuideType bcStaffingGuideType = new BcStaffingGuideType (this.ContextMoniker); //-//staffingGuideTypeProductivityFlag = bcStaffingGuideType.IsProductivityType(staffingGuideTypeID, dsStaffingGuide) ; //New Record? if(systemParameterID.Equals(-1)) { systemParameterRow = GetSystemParameterRow(systemParameterTypeID, personID, dsSystemParameter); } //Existing Record else { systemParameterRow = GetSystemParameterRow(systemParameterID, dsSystemParameter); } //if the system Parameter wasn''t located in the dataset if (systemParameterRow == null) { //if new record, then create new row if(systemParameterID.Equals(-1)) { systemParameterRow = dsSystemParameter.SystemParameter.NewSystemParameterRow(); } //else could not find record else { throw Utilities.GetMissingRecordException("SystemParameter"); } } //else, it was found, and attempting to add new, then raise an error else if (systemParameterID.Equals(-1)) { throw Utilities.GetDuplicateRecordException("SystemParameter"); } //update fields systemParameterRow.SystemParameterTypeID = systemParameterTypeID; systemParameterRow.PersonID = personID; //Used to work: systemParameterRow.SystemParameterEffectiveDate = Convert.ToDateTime(systemParameterEffectiveDate) ; //None of these work: //-//Indicates groups of lines tried together. //-//CultureInfo cultureInfo = new CultureInfo("en-US"); //-//DateTime dt = DateTime.ParseExact (systemParameterEffectiveDate, "D", cultureInfo); //-//systemParameterRow.SystemParameterEffectiveDate = dt; //DateTime dt = DateTime.ParseExact (systemParameterEffectiveDate, "dd/MM/yy", null); //-//systemParameterEffectiveDate = Convert.ToDateTime (systemParameterEffectiveDate).ToUniversalTime().ToString( format ); //-//systemParameterRow.SystemParameterEffectiveDate = Convert.ToDateTime(systemParameterEffectiveDate); //systemParameterRow.SystemParameterEffectiveDate = ParseDateTime(systemParameterEffectiveDate) ; //systemParameterRow.SystemParameterEffectiveDate = Convert.ToDateTime(systemParameterEffectiveDate).ToLocalTime() ; //systemParameterRow.SystemParameterEffectiveDate = DateTime.Parse(systemParameterEffectiveDate, // System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat); //systemParameterRow.SystemParameterEffectiveDate = System.DateTime.ParseExact(systemParameterEffectiveDate, @"yyyy\/MM\/dd HH:mm:ss", null); //systemParameterRow.SystemParameterEffectiveDate = System.DateTime.Parse("05/05/2005") ; //systemParameterRow.SystemParameterEffectiveDate = System.DateTime.Parse(systemParameterEffectiveDate) ; if (! systemParameterEndDate.Equals(String.Empty ) ) { systemParameterRow.SystemParameterEndDate = Convert.ToDateTime(systemParameterEndDate); //.ToLocalTime(); } else { //None of these work. //systemParameterRow.SystemParameterEndDate = System.DateTime.Now; //systemParameterRow.SystemParameterEndDate = DBNull.Value; //systemParameterRow.SystemParameterEndDate = Convert.ToDateTime(DBNull.Value.ToString()); //systemParameterRow.SystemParameterEndDate = Convert.ToDateTime(String.Empty.ToString()); //systemParameterRow.SystemParameterEndDate = DateTime.Parse(systemParameterEffectiveDate, // System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat); } systemParameterRow.SystemParameterValue = systemParameterValue; //if adding new record if(systemParameterID.Equals(-1)) { dsSystemParameter.SystemParameter.AddSystemParameterRow (systemParameterRow); } systemParameterRow.LastUpdateUser = lastUpdateUser; //systemParameterRow.LastUpdateDate = System.DateTime.Now; //Save Record SaveData(dsSystemParameter); // } public void SaveData(DsSystemParameter dsSystemParameter) { _dcSystemParameter.SaveTable( dsSystemParameter ); //cb temporary removed_dwSystemParameter.SaveData(0, dsSystemParameter); } ---------------------------------------------------------------------------- ---- (Save table just executes the stored proc called InsertSystemParameter)

Administrator [Syncfusion]
Replied On May 6, 2005 03:33 PM UTC

Are you using any Essential Grid control in your project?


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon