DataTable.Merge()从主表中丢失列

时间:2018-05-19 10:36:44

标签: c# .net winforms datagridview datatable

我有这段代码:

public void UcitajTargete()
{
    DataTable kom = new DataTable();
    DataTable mag = new DataTable();

    using (FbConnection con = new FbConnection(M.Baza.connectionKomercijalno2018))
    {
        con.Open();
        using (FbDataAdapter da = new FbDataAdapter("SELECT PPID, NAZIV, MOBILNI FROM PARTNER ORDER BY NAZIV", con))
        {
            da.Fill(kom);
        }
        con.Close();
    }
    using (FbConnection con = new FbConnection(M.Baza.connectionString))
    {
        con.Open();
        using (FbDataAdapter da = new FbDataAdapter("SELECT PPID, POSLEDNJI_PUT_PROPAGIRAN FROM PARTNER WHERE(POSLEDNJI_PUT_PROPAGIRAN >= 0)", con))
        {
            da.Fill(mag);
        }
        con.Close();
    }
    kom.PrimaryKey = new DataColumn[] { kom.Columns["PPID"] };
    mag.PrimaryKey = new DataColumn[] { mag.Columns["PPID"] };

    kom.Merge(mag);
    dataGridView1.DataSource = mag;
}

所以我想在PPID上合并这两个表,并将这些列作为结果:PPID | NAZIV | MOBILNI | POSLEDNJI_PUT_PROPAGIRAN

使用当前代码我得到PPID, POSLEDNJI_PUT_PROPAGIRAN

0 个答案:

没有答案