repair error?

  • 24 August 2007
  • 5 replies
  • 0 views

Badge +2

Each time I attempt to repair a particular error using Service manager, I get the message


"the error was not successfully repaired, please check DB log and try again"


 What am I supposed to do to fix this?

it's just a simple error... cannot convert srting "" to datetime.


5 replies

Badge +11

What does the code behind the error look like?


Can you post this code for us to look at?


Do you make any changes to the code before you try to repair it?


Regards,


Ockert

Badge +2

Sub Main(Byval K2 as EscalationRuleContext)
 Dim DateTime As DateTime
 Dim strDateTime As String
 If Not K2.ProcessInstance.DataFields("DespatchReminder").Value Is Nothing AndAlso K2.ProcessInstance.DataFields("DespatchReminder").Value <> "" Then
  strDateTime = K2.ProcessInstance.DataFields("DespatchReminder").Value


  DateTime = DateTime.Parse(strDateTime)
  K2.SetEscalationRule(DateTime)
 End If
End sub


error: Cast from string "" to type 'Date' is not valid.

any changes aren't applied since the repair fails.

Badge +4

Hi [Entry removed to customer request]


 It could be the date time formart is not compatible to the machines regional setting.


To repair, why don't we hard code the DateTime by change the code when you are repairing:


replace  DateTime = DateTime.Parse(strDateTime)
 with     DateTime = "28/08/2007 12:00:00 AM"
[ or 08/28/2007 if it is in US format]


 Repair it now


Hope this helps to resolve the problem

Badge +5

Hi,


I would definitely not recommend hard coding any values into that code window because that will change the code inside the database, which will result in a re-export of the process.


The error lies in the following code : "AndAlso K2.ProcessInstance.DataFields("DespatchReminder").Value <> "" ".


You don't need this as the field will either return Nothing or a DateTime value type. If "DespatchReminder" is not in a valid format it will return "1900/01/01" depending on your regional settings.


Please remove or change this code and try to repair the error.


Regards


Gert


 

Badge +2

you were right...
comparing the value of a datetime type datafield to an empty string means that the empty string needs to be converted to a datetime before the comparison can take place.
All this time i thought the datafield was being given an empty string value somewhere.
thanks.

One interesting point though...
one thing that i did was comment out all lines that referred to the datafield, including the IF block.
this repair still failed.
that's why i posted here to find out how to repair the error.

this whole problem may be due to another problem we were experiencing:
"an error occurred in the compilation of the process."
occurs when StartProcessInstance was called.


a re-export of the K2 solution fixed this one. and may also have enabled me to successfully repair the error.

Thank you all for all your help.

Reply