Layer Management Learning in SDE

Source: Internet
Author: User

Original posted Address: http://www.cnblogs.com/columbus2/archive/2007/09/14/892679.html

Private Sub CommandButton1_Click () adds a local shape file to the SDE server

If TextBox1.Text = "" Then
MsgBox "Missing upload file. ", vbcritical," warning "
Exit Sub
End If

Dim Fwor as Ifeatureworkspace
Dim WFAC as Iworkspacefactory
Dim fCla1 as Ifeatureclass, FCLA2 as Ifeatureclass
Dim ProSet as Ipropertyset
Dim Fcount as Integer
Dim FEA as Ifeaturebuffer
Dim Geo as Igeometry

Dim sfile, sname, spath as String
Sfile = TextBox1.Text
spath = Sfile
Sname = Right (spath, 1)
Do as not (sname = "/")
spath = Left (spath, Len (spath)-1)
Sname = Right (spath, 1)
Loop
Sname = Right (Sfile, Len (sfile)-Len (spath))
spath = Left (spath, Len (spath)-1)
Set WFAC = New shapefileworkspacefactory
Set fwor = Wfac.openfromfile (spath, None)
Set fCla1 = Fwor.openfeatureclass (sname)
Fcount = Fcla1.featurecount (Nothing)

Set WFAC = New sdeworkspacefactory
Set ProSet = New PropertySet
Proset.setproperty "Server", "Yj-gis2"
Proset.setproperty "instance", "5151"
Proset.setproperty "User", "SDE"
Proset.setproperty "Password", "SDE"
Proset.setproperty "Version", "DEFAULT"
Set fwor = Wfac.open (proSet, 0)
Set FCLA2 = Fwor.createfeatureclass (Fcla1.aliasname, Fcla1.fields, Fcla1.clsid, Fcla1.extclsid, FCla1.FeatureType, Fcla1.shapefieldname, None)

Dim Wedit as Iworkspaceedit
Set Wedit = Fwor
Wedit.startediting True
Wedit.starteditoperation

For i = 0 to FCount-1
Set FEA = Fcla2.createfeaturebuffer
Set Geo = fcla1.getfeature (i). Shapecopy
Set FEA. Shape = Geo
Dim Fdcount as Integer
Fdcount = FCla1.Fields.FieldCount
For j = 0 to FdCount-1
Fea. Value (j) = Fcla1.getfeature (i). Value (j)
Next J
Fcla2.insert (True). Insertfeature (FEA)
Next I

Wedit.stopeditoperation
Wedit.stopediting True


MsgBox "added successfully. ", vbinformation," hint "

End Sub

Private Sub CommandButton2_Click () removes layers on SDE server

Dim FName as String
FName = Combobox1.text

Dim Fwor as Ifeatureworkspace
Dim WFAC as Iworkspacefactory
Dim ProSet as Ipropertyset
Dim FSet as Idataset

Set WFAC = New sdeworkspacefactory
Set ProSet = New PropertySet
Proset.setproperty "Server", "Yj-gis2"
Proset.setproperty "instance", "5151"
Proset.setproperty "User", "SDE"
Proset.setproperty "Password", "SDE"
Proset.setproperty "Version", "DEFAULT"
Set fwor = Wfac.open (ProSet, None)
Dim wor as Iworkspace
Set wor = Fwor

Set FSet = Fwor.openfeatureclass (fName)
Fset.delete

MsgBox "Delete succeeded. ", vbinformation," hint "

End Sub

Private Sub Commandbutton3_click () ' Browse local shape file

Commondialog1.filter = "Shape file|*.shp"
Commondialog1.filename = ""
Commondialog1.showopen
If commondialog1.filename <> "" Then
TextBox1.Text = Commondialog1.filename
End If

End Sub

Private Sub Commandbutton4_click () ' lists the layers on the SDE server in the Drop-down menu

Combobox1.text = ""
Combobox1.clear

Dim Fwor as Ifeatureworkspace
Dim WFAC as Iworkspacefactory
Dim ProSet as Ipropertyset

Set WFAC = New sdeworkspacefactory
Set ProSet = New PropertySet
Proset.setproperty "Server", "Yj-gis2"
Proset.setproperty "instance", "5151"
Proset.setproperty "User", "SDE"
Proset.setproperty "Password", "SDE"
Proset.setproperty "Version", "DEFAULT"
Set fwor = Wfac.open (ProSet, None)
Dim wor as Iworkspace
Set wor = Fwor
Dim ESet as Ienumdataset
Set ESet = wor. Datasets (Esridtfeatureclass)
Dim Fcla as Ifeatureclass
Set FCLA = Eset.next
While not Fcla are nothing
ComboBox1.AddItem Fcla.aliasname
Set FCLA = Eset.next
Wend

MsgBox "updated successfully. ", vbinformation," hint "

End Sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.