Hi experts,

I am not sure if I should use Merge on this case, but I want to add a
Vendor Name column in the datagrid1 where the Vendor Name has to get
from another server (not linked and can't be linked).
The first table contains Job tracking information, which has a
"J_Vendor_ID" column, and no Vendor Name in this server.
The 2nd table on the other server contains VendName and VendorID.
I want to have a Vendor Name column (VendName) in datagrid, and
VendName column has to get from the 2nd table, the VendName should
list only from table1's the VendorID.
The J_vendor_ID from table1 and VendorID from table 2 will be the key
columns for the 2 datasets merging.

I received error when it's doing the dataSet.Merge(dataSet2):

System.Data.DataException: Mismatch columns in the PrimaryKey :

Re: Urgent~ How to merge 2 datasets in 1 DataGrid? by Grzegorz

Grzegorz
Fri Oct 22 17:09:00 CDT 2004

Uzytkownik "JenHu" <jenniferhu46@hotmail-dot-com.no-spam.invalid> napisal w
wiadomosci news:417965a6$1_3@Usenet.com...
> Hi experts,
>
> I am not sure if I should use Merge on this case, but I want to add a
> Vendor Name column in the datagrid1 where the Vendor Name has to get
> from another server (not linked and can't be linked).
> The first table contains Job tracking information, which has a
> "J_Vendor_ID" column, and no Vendor Name in this server.
> The 2nd table on the other server contains VendName and VendorID.
> I want to have a Vendor Name column (VendName) in datagrid, and
> VendName column has to get from the 2nd table, the VendName should
> list only from table1's the VendorID.
> The J_vendor_ID from table1 and VendorID from table 2 will be the key
> columns for the 2 datasets merging.

In my opinion, Instead of using merge you should use expression column, for
example:

1. add to DataSet both tables ("Job tracking information|" and "VendName and
VendorId"),
2. add relation between those tables:

ds.Relations.Add("VendorId_VendorName", _
ds.Tables("PM00200").Column("VendorId"), _
ds.Tables("Job_Tracking_Table").Columns("J_Vendor_ID"),
_
False)

3. add expression column to Job_Tracking_Table:

ds.Tables("Job_Tracking_Table").Columns.Add("VendorName", GetType(String), _
"Parent(VendorId_VendorName).Vendname")

Regards,
Grzegorz