Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a table that is in SDE, what I want to do is in my userform click on the "Save" button, and the table will be edited even though it is not within the map document. Is this possible? I have tried the following code, which runs, but nothing happens to the table (I have also added the table to the map document and still nothing happens or no error messages occur). Here is that I have code.

Private Sub cmdSaveDev_Click()

Dim pTable As ITable
Dim pCursor As ICursor
Dim pRow As IRow
Dim pRowBuffer As IRowBuffer

Dim pPropset As IPropertySet
Set pPropset = New PropertySet
    With pPropset
        .SetProperty "Server", "***"
        .SetProperty "Instance", "***"
        .SetProperty "User", "***"
        .SetProperty "Password", "***"
        .SetProperty "Version", "SDE.DEFAULT"
    End With

Dim pSdeWS As IWorkspace

Dim pSdeWF As IWorkspaceFactory
Set pSdeWF = New SdeWorkspaceFactory

Dim pSdeFeatWS As IFeatureWorkspace
Set pSdeFeatWS = pSdeWF.Open(pPropset, 0)

Set pSdeWS = pSdeFeatWS

Dim pWkspEdit As IWorkspaceEdit
Set pWkspEdit = pSdeFeatWS


Dim i As Integer

If lstSelectedDevelopers.ListCount = 0 Then
    MsgBox "Add a developer to the Selected Developer box and try again"

    pWkspEdit.StartEditing (True)

    Set pRowBuffer = pTable.CreateRowBuffer
    Set pCursor = pTable.Insert(True)
    For i = 0 To lstSelectedDevelopers.ListCount - 1
        Set pRow = pRowBuffer
        pRow.value(1) = frmCityDev.txtRecordNo
        pRow.value(2) = lstSelectedDevelopers.List(i)

    Next i

    pWkspEdit.StopEditing (True)

End Sub


share|improve this question
up vote 4 down vote accepted

Yes you can, but you have things out of order and one important step missing

This should be your order:

 get insert cursor
 create rowbuffer
 do your edits
 insertcursor.insertrow(buffer) <---- missing

You may want to look at this example

share|improve this answer
Perfect thanks, I've got it working!!!! – MapMan Jan 26 '12 at 17:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.