LINQ to copy one data table values to newly build data table

Hi everyone,

I have a huge excel and I need to bulk upload data into a database.

The problem I’m facing is the excel is returning data table with random data type so I need to change data type of column plus I need to assign it new Data table since DB column name are different then excels

Can some one help me with linq query for this use case.

Hi @kishore.shetty1,

Use following query

(From dr1 in DT.AsEnumerable() Select Newdt.LoadDataRow(New Object() {dr1(“Whs”).ToString, Cint(dr1(“FL”).toString)},false)).CopyToDataTable

DT= source table
Newdt = destination table (you need to build this table columns first

Please ask if you need any help

Happy Automation


Thank for the help. Got it working :slightly_smiling_face:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.