地圖 資料集串連

來源:互聯網
上載者:User

串連表:

Udb資料檔案中同一資料來源下有兩個資料集。要把這兩個資料集的表串連起來:

在這裡用joinIte-m-

Reason:

建立串連的兩個表必須在同一個資料來源下,而用於建立關聯關係的兩個資料集表可以不在同一個資料來源下。

 

//////////////////////////////////////////

按下面的代碼,可以實現  市表 和省表串連起來。先是市表欄位在接上省表的欄位。當欄位中有重複名的時候,自動改寫成  表名.原欄位名  加以區別。  當然如果指定顯示內容可以用queryParameter的ResultField屬性

/////////////////////////////////////////

 

Code:

private void Initialize()

{

WorkspaceConnectionInfo conInfo = new WorkspaceConnectionInfo(@"swmu地址");

m_workspace.Open(conInfo);

JoinItemSample(m_workspace.Datasources["名"]);

}

public void JoinItemSample(Datasource datasource)
{
    DatasetVector datasetVector = datasource.Datasets["市表"] as DatasetVector;
    DatasetVector datasetVector1 = datasource.Datasets["省表"] as DatasetVector;
    // 構造串連資訊類對象,獲得用於串連的表名
    JoinItem joinitem = new JoinItem();
    // 設定串連資訊類的屬性
    joinitem.ForeignTable = datasetVector1.TableName;
    joinitem.JoinFilter = "省表.id=市表.id";
    joinitem.JoinType = JoinType.LeftJoin;
    QueryParameter para = new QueryParameter();
    para.JoinItems.Add(joinitem);
    Recordset recordset = datasetVector.Query(para);
    string strField = "";
    for (int j = 0; j < recordset.FieldCount; j++)
    {
      strField = strField + "," + recordset.GetFieldInfos()[j].Name;
    }
    MessageBox.Show(strField);
    recordset.MoveFirst();
    if (!recordset.IsEOF)
    {
        string str = "";
        for (int i = 0; i < recordset.FieldCount; i++)
        {
            object oo = recordset.GetFieldValue(i);
            if (oo != null)
            {
                str = str + "," + oo.ToString();
            }
                    
        }
        MessageBox.Show(str);
        //  recordset.MoveNext();
    }
    recordset.Dispose();         
}

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.