Reputation: 10344
I have two DataTables which has the following rows.
Table A:
TaxID TaxName
------ --------
1 VAT
2 Sales Tax
Table B:
TaxID TaxName
----- --------
1A ED
2A Discount
In Table A: The datatype for the column TaxID is INT In Table B: The datatype for the column TaxID is String.
Now I want to merge these two tables.
I tried like this:
TableA.Merge(TableB);
But it gives error.
how to achieve this?
Upvotes: 1
Views: 1855
Reputation: 460048
You cannot change a DataColumn's DataType after the Datatable was populated with data. So you should cast it with SQL to the appropriate type(varchar
) before you fill it.
For example:
SELECT CAST(TaxID as varchar(5))AS TaxID, TaxName FROM TableA
Upvotes: 4