Getting error "assign exception has been thrown by the target of an invocation"

Can you please paste the complete exception message here? Without that it’s impossible to tell what the issue might be.

Assign: Exception has been thrown by the target of an invocation.

No, no, that’s not enough. Look at the screenshot in my post here - Getting error "assign exception has been thrown by the target of an invocation" - #18 by Alexandru-Luca

Run your project from Studio. When you get the exception pop-up window, click on Details and get the whole stack trace. Paste that here, please.

EDIT: it seems that you’re trying to assign a value to a column that does not exist in your DataTable. Please double-check that the column’s name is correctly spelled and that column actually exists.

If that’s not it, please copy & paste the exception stack trace here… The Inner exception is not visible from the screenshot :slight_smile:

1 Like

20.6.0-beta.93+Branch.release-v20.6.0.Sha.520fc7e20bd9baa56becf2fa30e75d1a9000a01d

Source: Insert

Message: Incorrect syntax near the keyword ‘from’.

Exception Type: System.Data.SqlClient.SqlException

RemoteException wrapping System.Data.SqlClient.SqlException: Incorrect syntax near the keyword ‘from’.

Server stack trace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SqlClient.SqlCommandBuilder.GetSchemaTable(DbCommand srcCommand)
at System.Data.Common.DbCommandBuilder.BuildCache(Boolean closeConnection, DataRow dataRow, Boolean useColumnsForParameterNames)
at System.Data.Common.DbCommandBuilder.GetInsertCommand(DataRow dataRow, Boolean useColumnsForParameterNames)
at System.Data.Common.DbCommandBuilder.GetInsertCommand()
at UiPath.Database.DatabaseConnection.InsertDataTable(String tableName, DataTable dataTable)
at UiPath.Database.Activities.InsertDataTable.<>c__DisplayClass29_0.b__0()
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object args, Object server, Object& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)

Exception rethrown at [0]:
at UiPath.Database.Activities.InsertDataTable.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

Hi @swanand_deshmukh! This is obviously a different error about an incorrect SQL syntax. Check & correct the SQL query and try again. You should not have any trouble in finding ample material regarding SQL on the net.

Cheers,
Alex.

actually im using insert activity while inserting into database

Thank you! I have been struggling with exactly this issue!

Hey there - I was experiencing this same error while using the gSheets library. When I tried to assign a value to a cell it would throw this exception.

I saw the other answers but in my case it turned out that when I started the project I was reading only from Column A of the sheet. Later I added columns but I never went back and expanded the scope for the “read sheet” activity so when I tried to write to the cell it was out in one of the new columns that existed in the sheet but did not exist in the scope of the data table within UiPath.

Changing the read activity to include the new columns and rows solved the issue.

An easy enough mistake to make as you develop iteratively but I wanted to share in case anybody else made the same error. :slight_smile:

Hi All,

I want to add that whenever your data have two identical column names then the run exception has raised. It is the case with me and I renamed one column name and issue is resolved now.

Many thanks,

1 Like

I had the same problem and the solution was that I forgot of create the Column. I added a Add Data Column in my datatable and solved it. try check something related about it.

1 Like

This one did it for me. Thanks bro. You’re a genius!

1 Like

Thanks alot, I also getting same error due to MaxLength of this column, after increasing the length, problem solved

1 Like

hello how can i do this

Hi @Ertan_Ay2!

Sorry, I do not understand your question :slight_smile: