Hi guys, I have the following task at hand I need to get all the users and their pass and DB from a certain SQL DataBase and from there assign them to different arrays.
However the issue seems to be that some of the values in the “db” field appear to set to NULL and I get the below error:
Message: Object reference not set to an instance of an object.
Exception Type: System.NullReferenceException
RemoteException wrapping System.NullReferenceException: Object reference not set to an instance of an object.
at lambda_method(Closure , DataRow )
2.MoveNext() at System.Linq.Buffer1…ctor(IEnumerable
1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at lambda_method(Closure , ActivityContext )
1.Execute(CodeActivityContext context) at System.Activities.CodeActivity1.InternalExecuteInResolutionContext(CodeActivityContext context)
at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance, Activity
1 expressionActivity) at System.Activities.InArgument1.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityExecutor executor)
at System.Activities.RuntimeArgument.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityExecutor executor, Object argumentValueOverride, Location resultLocation, Boolean skipFastPath)
at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument, Int32 nextArgumentIndex, ActivityExecutor executor, IDictionary
2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate) at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary2 argumentValueOverrides, Location resultLocation, Int32 startIndex)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
Furthermore I changed the NULL values to 0 or null (with lowercase) and it stops giving me that message, however I am allowed to do this for debugging purposes so at production time I would not be able to mess around with the Data Base values.
So any advise how to add the NULL value to my array ? At the moment I am using an “Assign” activity to do this and the expression which I am using is “Users.AsEnumerable().Select(Function (a) a.Field(of string)(“db”).ToString).ToArray()”
Also on a side note is there a way to filter an array so it does not include certain users and assign that to a new array ?
Thank you very much