[Workaround] System.ArgumentException when removing argument from Execute Query block

Short Description
When attempting to remove a parameter from an Execute Query (App Integration → Database), the parameter fails to be removed.

Attempting to close the Edit SQL block after this results in an exception causing UiPath Studio to close.

Exception Text:

19.4.2+Branch.master.Sha.e17a3bedca2a7da0d0b716b5f8f765d1d5ef1ddc

An internal error has occurred. It is recommended to restart UiPath Studio.

Error: System.ArgumentException: An item with the same key has already been added.
   at System.Activities.Presentation.DictionaryItemsCollection`2.InsertItem(Int32 index, ModelItemKeyValuePair`2 item)
   at System.Collections.ObjectModel.Collection`1.Add(T item)
   at System.Collections.ObjectModel.Collection`1.System.Collections.IList.Add(Object value)
   at System.Activities.Presentation.Model.ModelItemCollectionImpl.AddCore(ModelItem item)
   at System.Activities.Presentation.Model.CollectionChange.ApplyInsert()
   at System.Activities.Presentation.Model.CollectionChange.Apply()
   at System.Activities.Presentation.Model.EditingScope.OnRevert(Boolean finalizing)
   at System.Activities.Presentation.Model.ModelEditingScope.Revert()
   at System.Activities.Presentation.Model.ModelEditingScope.Dispose(Boolean disposing)
   at System.Activities.Presentation.Model.ModelEditingScope.Dispose()
   at UiPath.Database.Activities.Design.GenericDatabaseDesigner.SqlButton_Click(Object sender, RoutedEventArgs e)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Button.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler), HResult -2147024809

Restarting the app does not appear to have any effect. Likewise, deleting the SQL Query block and recreating it has no effect. I do believe this points to an error in my project, however I’ve noticed the project file does not appear to match what I would expect given the designer. Here’s the relevant xml block and a screenshot of how things appear in my designer.

Restarting the designer as recommended failed twice to produce any changes, which is why I a making this post. On the third time, I opted not to restart and manually deleted the execute query block and saved before manually restarting. After recreating the execute query block, I seem to have achieved a non-error state. So while this is technically resolved, I felt it pertinent to inform the developers to the nature of the issue.

2 Likes

Hi @Foxtrek_64
Show the error message of connect execute Query

Th@nks
@shwin S

1 Like

Yah this happened many times for others here in forum and me as well
just in simple assign activity a datarow value fetching will throw syntax error but the syntax would be correct… and if we recreate the same activity again it wont appear…
i wonder many times why this happens…hmm…
thanks for sharing this info buddy
would let you know if i come to know any resolution

edit: would like to know the error that came up with EXECUTE QUERY, i mean the one we get from the activity (that blue exclamatory) @Foxtrek_64
Cheers @Foxtrek_64

1 Like

In the query window itself, was getting 'Id ' is not declared. It may be inaccessible due to its protection level.

The error on the property window said Invalid L-Value Expression

Hi @Foxtrek_64

Could you maybe attach a small project for me to try? It doesn’t have to contain any sensitive data, just a ‘broken’ behaviour that is reproduced.

I’ve been trying for a few hours now on and off between other tasks but I can’t seem to find a way to replicate this unfortunately. The link to the xml snippet should be able to be dropped into a new project - just remove the <!-- snip --> blocks (I’m not sure if that’s within the xaml schema we use) and reconfigure the database connection to point somewhere proper. It’ll probably work properly though, knowing my luck.

Hi @Foxtrek_64

Is id been declared

Thanks
Ashwin.S

As you can see in the gif at the top of the original post, Id is declared as an In/Out parameter within the scope of the SQL block.

Initially this was only an In parameter, however I changed it to just to see if I could get any changes to be preserved. Once I changed it, it remained stuck as an in/out parameter until my resolution steps at the bottom of the original post.

Hi @Foxtrek_64

Print the id value before the executing query and ensure you print the id argument as out

Thanks
Ashwin S