将ESRI.ArcGIS.Geodatabase中的Table对象转为System.Data.datatable对象
Posted on 2008-08-14 17:16 小玮 阅读(907) 评论(0) 收藏 举报'///实现将ESRI.ArcGIS.Geodatabase中的Table对象转为System.Data.datatable对象。
Public Function ConvertITable(ByVal table As ITable) As DataTable
Dim dt As DataTable
dt = New DataTable("datatable")
Try
Dim pQueryFilter As IQueryFilter = New QueryFilterClass()
Dim pCursor As ICursor = table.Search(pQueryFilter, True)
Dim pRow As IRow = pCursor.NextRow()
If pRow IsNot Nothing Then
For i As Integer = 0 To pRow.Fields.FieldCount - 1
dt.Columns.Add(pRow.Fields.Field(i).Name)
Next
While pRow IsNot Nothing
Dim pDataRow As DataRow = dt.NewRow()
For j As Integer = 0 To pCursor.Fields.FieldCount - 1
pDataRow(j) = pRow.Value(j)
Next
dt.Rows.Add(pDataRow)
pRow = pCursor.NextRow()
End While
End If
Catch ex As System.Exception
MessageBox.Show(ex.Message)
End Try
Return dt
End Function
浙公网安备 33010602011771号