Insert datatable to sql table problem

Hi,

I have a datatable and want to insert it into sql table. The problem is, there are some empty cells in few columns. I am facing error when trying to insert the rows of datatable which has any empty cell. The error is:
image

Any help in this regard?

Hi @WASEEM_KHAN,

By the look of this error, it looks to me that the the insert command needs to cast the parameter to the correct data type within SQL. The column you are trying to insert looks to be of type Int32 but the insert command is trying to insert a String value.

Hi,

@jeevith Yeah! I overlooked it. The datatype of column of sql table is int but datatable column is of object type. Now, to match the datatype, I am copying the this datatable to new datatable where I choose the datatype of column to be int32. The problem is, when I copy rows of old datatable to new datatable, I face error due to to empty cells which is:

Add Data Row: Input string was not in a correct format.Couldn’t store <> in Material Column. Expected type is Int32.

Note: I do not want to use any custom libarary. How can I copy old datatble to new datatable so taht I can write it into sql?