Showing posts with label string. Show all posts
Showing posts with label string. Show all posts

Saturday, February 25, 2012

Records not updating in Script Component

I am seeing a strange behavior in a script component that I can't figure out.

Basically, there is a field in my script that checks to see if a string field is length of 1. If it is, it updates the field with some value. The strange behavior is that it picks up some of the rows but not others.

If Row.FieldValue.Length = 1 Then

Row.FieldValue= "Some Value"

End If

I've tried variations such as:
If left(Row.FieldValue.,1) = "-" Then


Row.FieldValue= "Some Value"


End If

But I get the same results. Any Ideas?Does [Field] need to be trimmed? Might some data contain trailing white spaces?|||

No, I've tried every combination of Trim, left, equals etc...that I can think of. The funny thing is that it picks up some of the fields and misses others.

Very puzzling. I was hoping to hear of some rare condition on this board that sounds similar to this, but I have yet to hear of any similar situations.

The code that I am talking about is incredibly simple, as shown in my previous post.

|||What happens when [Field] is null?|||

You could fire some debug iformation to help you. Something like this maybe:

Me.ComponentMetadata.FireInformation(,,Row.FieldValue.ToString() + " - " + Row.FieldValue.Length.ToString(), ....

-Jamie

|||

Thanks, that did it. I am relatively new to SSIS, never really delved into the debug information before.

that is very helpful.

|||

KML67 wrote:

Thanks, that did it. I am relatively new to SSIS, never really delved into the debug information before.

that is very helpful.

Great! But what solved your issue?|||

Basically, matching the string by length, equal, explicit match was working fine all along.

There was some logic that followed this string test that was providing the error. The error was very subtle, so it did not always produce the same value for the same input (depending on multiple variables), but at quick glance (watching the data flow into and out of the component with dataviewers) it looked as like there was an inconsistency in the component itself.

Jamie's post was very helpful, I am new to SSIS and wasn't familiar with the fireInformation method. That allowed me to solve it in a second.

Thanks for the tips, this board is a great asset.

Monday, February 20, 2012

Record Selection Formula. Impossible?

I have a problem selecting records in my crystal report. There are two string parameters, dateFrom and dateTo. The record selection formula is:

{payroll_history.dateModified} in CDate({?dateFrom}) to CDate({?dateTo})

When typing in the string parameters in crystal, the report works fine, suggesting the fault is in the parsing from vb to crystal. See code below:

Report.Parameters.getItemByName("dateFrom").setCurrentValue(strDateFrom)
Report.Parameters.getItemByName("dateFrom").setCurrentValue(strDateFrom)

HOWEVER, I can display these parameters on the screen perfectly fine when executing the report from VB. Surely this means the selection formula is incorrect?? But it works from within crystal! Argh!

Any help anyone can give me will be so much appreciated.My first thought is that you have a DateTime field, but are trying to use a string parameter. Is payroll_history.dateModified a DateTime field in the database? If so, you need to pass it a DateTime. Also, if it is DateTime and not just Date, you will need to add the hour which, if you don't use a time, will have to be 00:00:00, so the parameter passed would have to be something like 08/12/2006 00:00:00 or else it won't work.