Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

Set pTable = pSdeFeatWS.OpenTable("SY_CSY_TERRIER.DEVELOPMENT_DEVELOPER")

Dim i As Integer

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

    pWkspEdit.StartEditing (True)
    pWkspEdit.StartEditOperation

    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)

        pCursor.Flush
    Next i

    pWkspEdit.StopEditing (True)
    pWkspEdit.StopEditOperation

End Sub

Thanks!

share|improve this question
add comment

1 Answer 1

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:

 startediting
 starteditoperation
 get insert cursor
 create rowbuffer
 do your edits
 insertcursor.insertrow(buffer) <---- missing
 stopeditoperation
 stopediting(save)

You may want to look at this example

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

Your Answer

 
discard

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.