How to edit SDE data (from ESRI China Community)(17:26:41)
Tags: AE DevelopmentIt |
Category: ArcSDE |
Many beginners do not know much about SDE data. Sometimes they may not be able to answer questions in the Community one after another, and they are also very sympathetic to this lazy goat. Thinking of the pain of getting started, lazy goat decided to write time to explain in detail how to edit SDE data, hoping to grow with the majority of new users and spend the difficult time getting started. If there are any errors or vague descriptions, please turn your fingers to the correct ones.
A spatial data engine developed by SDE vector ESRI, which can use the good management advantages of the file database to manage data graphics and attributes. AccessDatabase and FileGeoDataBase can also manage data well, but the biggest difference with SDE databases is that they do not support simultaneous editing by multiple users, that is, SDE version technology. Although we all know this, we should mention it by the way.
Many people may stay focused on the operations on shp files or MDB files when they first come into contact with SDE data. In fact, most of their operations are consistent, but the access methods are different. Because SDE has a version control, there is a big difference between loading data and opening FeatureClass. Next we will start to discuss how to operate SDE data.
1. Open the SDE data.
The SDE data must be initialized using the workspace factory and opened in the workspace FeatureClass, which is the most common operation. Next, connect to SDE through a piece of C # code, open and return an IWorkspace.
Public IWorkspace FindWsByDefault ()
{
IPropertySet propSet = new PropertySetClass ();
PropSet. SetProperty ("Server", Lan );
PropSet. SetProperty ("Instance", yangyang );
PropSet. SetProperty ("Database ","");
PropSet. SetProperty ("User", user );
PropSet. SetProperty ("Password", pwd );
PropSet. SetProperty ("Version", version );
IWorkspaceFactory factory = new SdeWorkspaceFactoryClass ();
IWorkspace workspace = factory. Open (propSet, 0 );
Return workspace;
}
The above code opens the SDE workspace. The next step is to get the FeatureClass to be edited. Write a function and return FeatureClass through the alias of FeatureClass and the Dataset. The method is to traverse all DataSet first, find the qualified Dataset, traverse the elements, and return the FeatureClass consistent with the involved aliases (by the way, featureClass has the same name as FeatureClass by default when no alias is specified)
// Find the specified Element
Public IFeatureClass FindClassByName (IWorkspace ws, string className, string dsName)
{
IEnumDataset enumDs;
If (dsName! = "")
{
EnumDs = ws. get_Datasets (esriDatasetType. esriDTFeatureDataset );
IFeatureDataset featureDs = enumDs. Next () as IFeatureDataset;
While (featureDs! = Null)
{
If (featureDs. Name = dsName)
{
Return GetFcFromDataset (featureDs, className );