Posted: 15 Jul 2018 20:11 EDT Last activity: 6 Nov 2018 20:02 EST
Excel Export to Lookup table is throwing "Column does not accept null values"
Question 1: I am trying to export data from excel to lookup table, but I am getting an error message like "Column does not accept null values". I have maintained the same column name in both excel and look up. Please provide a solution for this issue, attached automation snapshot and stack trace.
Question 2: How to access the excel or lookup list in script component? I am trying to compare the expected and actual values from two lookup lists. Can you please share a code snippet to follow?
1. You'll need to create a script to manipulate the data from the ExportData method to essentially replace the DBNull values with something else. I created a script below that replaces them with string.Empty. This wouldn't work for a table with only one column though, as the first column is a key field and must be unique. You might want to make a change and skip any rows where dr is DBNull rather than replacing it with something else.
2. To pass the DataTable returned by ExportData in a script, simply add the DataTable as an input parameter to your script method as shown below and then pass it directly in. You can do the same with the LookupTable by calling the GetTable method which returns a DataTable that you can manipulate in a script with C#.
public DataTable ReplaceDBNulls(DataTable dataTable)