Insert empty column of excel into sql

I have one Excel file there are some columns that do not have any value.I want to insert the data into SQL when I run the workflow it shows I cannot find column 21. This error occurs because column no 21 is empty.

Hey @Cuberoot ,

Is column exists in the Datatable variable after reading from excel?

Thanks,
Sanjit

1 Like

yes.it exists

Can you please attach a screenshot here of datatable with 21st column


input file

The number of columns are 21, but the index of first column is 0 and last column is 20, so to access the last column you need to put 20 instead of 21, while entering the value to database.

I have found the solution.Do you know how to resolve this-

thanks. yes when I shared the image then I realized this

1 Like

@Cuberoot

Please use log message and print the sql statement so that we can see what the syntax error is

Cheers

right now I am getting this error-

@Cuberoot

Either connection string is wrong

if that is not true then please try changing the database package version and check mostly 1.6 works

cheers

after downgrade the package form 1.7.1 to 1.6.1 it shows me the below error:

Hi @Cuberoot

Iterate through the columns of the DataTable using a For Each activity. Set the TypeArgument property of the For Each activity to System.Data.DataColumn.
Within the loop, check if the column is empty using an If activity. You can use the IsNullOrWhiteSpace method to check if the column is empty.

Example-

The Condition to check if a column at index 20 (column number 21) is empty:-

String.IsNullOrWhiteSpace(row.Item(20).ToString)

Thanks!!

@Cuberoot

Did you happen to install the data providers?

Cheers

how to install data providers

@Cuberoot

Here you have for sql server

If using some other db then downlod accordingly

Cheers

is it suitable for oracle ?

@Cuberoot

For oracle can use this…check the compatibility depending on version youa re using

Cheers

Should I download both ?

@Cuberoot

You can download any one …one is odbc drivers and other is oledb drivers…anything can be used…the connection string should be created accordingly using the installed driver

Cheers