Empty rows while sending data into sql giving error

I have an excel sheet which contains some data and it contains some empty rows which is giving below mentioned error while inserting the data into sql.
The error is:-
System.FormatException: Failed to convert parameter value from a String to a DateTime.
—> System.FormatException: String ‘’ was not recognized as a valid DateTime.
at System.Convert.ToDateTime(String value, IFormatProvider provider)
at System.String.System.IConvertible.ToDateTime(IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at Microsoft.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType, Boolean& coercedToDataFeed, Boolean& typeChanged, Boolean allowStreaming) in D:\a_work\1\s\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlParameter.cs:line 2238
— End of inner exception stack trace —
at UiPath.Database.Activities.InsertDataTable.HandleException(Exception ex, Boolean continueOnError)
at UiPath.Database.Activities.InsertDataTable.ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
at UiPath.Database.Activities.AsyncTaskCodeActivity.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)
The sheet is-
Test2 (1).xlsx (10.3 KB)
How should I treat the empty value to send in date column structure as it is coming as string.
Thanks in advance!!

Does your DB in which you are trying to add accepts NULL on the column ‘Date4’? If yes, replacing the value from col ‘Date4’ with ‘Nothing’, making sure it’s not a string.

If your DB does not allow NULLs, change the setting so it does and try above.

Might be helpful to share the workflow as well.

Hi @Delia_Panca
Yes,It is accepting Null values.
Can you help me with a workflow to understand what change I need to make to make it Nothing so it can take date value.
Thanks in advance!!

Something like this. I have added the write line to check the type of that field, and in my Output I had System.Datetime

Let me know if it works

Edit: the for each must be added before you are trying to insert the table in the DB.

1 Like

DateTime data insert to sql server - Help / Studio - UiPath Community Forum you can also refer to this