Datatables headers


#1

Hi,

Scenario:-I am writing a datable in the SQL server databse.My dt has one column “Employee Name” whici I cant change.

Now,if in my database table I create a coulmn “Employee Name” I am not able to write the data.

Datatable header Database table column result
Employee Name Employee Name Failure
EmployeeName EmployeeName Success
Employee Name EmployeeName Failure
EmployeeName Employee Name Failure

So only when datatable header and database table column matches and doesnt have any space between “Emploee” and “Name” then only it is writing in database.

I am creating the dt from excel and I cant change excel headers.

Is there any way to accomplish this? Can we remove spaces between “Employee” and “Name” from headers or any other approach?

Thanks,
Pulkit Gupta


#2

@PULKITGUPTA

Did you try changing the data table column name before writing into SQL database?
dataTable.Columns[“Employee Name”].ColumnName = “EmployeeName”