File GeoDatabase向表中添加字段
File GeoDatabase向表中添加字段
Try
{
IWorkspaceFactory pGDBworkspaceFactory = new FileGDBWorkspaceFactoryClass();
IWorkspace pGDBWorkspace =GDBworkspaceFactory.OpenFromFile(@"D:\GIS\GuangYuan\GuangYuan.gdb", 0);
IFeatureWorkspace pFeatureWorkspace = (IFeatureWorkspace)pGDBWorkspace;
ITable pTable = pFeatureWorkspace.OpenTable("RasterData");
IFieldsEdit pFieldsEdit = (IFieldsEdit)pFields;
IFieldEdit pFieldEdit = new FieldClass();
pFieldEdit.Name_2 = "A1"; //不能以数字开头
pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
pFieldEdit.Length_2 = 10;
pFieldsEdit.AddField(pFieldEdit);
IField pField = new FieldClass();
pField = pFieldsEdit.get_Field(0);
pTable.AddField(pField);
MessageBox.Show("成功添加字段!");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
posted on 2009-03-25 10:00 kisstome88 阅读(528) 评论(0) 编辑 收藏 举报