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.

First of all, I want to update a table, not a feature class (no geographical information). I tried the following

Public Sub updateInSql(tableName As String, whereClause As String, field As String, value As String)

    ' get table
    Dim pTable As ITable: Set pTable = getTableFromSQL(tableName) ' this is my function that gets the table object (it works for sure)
    If (pTable Is Nothing) Then Exit Sub

    Dim pQueryFilter As IQueryFilter: Set pQueryFilter = New QueryFilter
    pQueryFilter.whereClause = whereClause
    If (whereClause = "") Then Set pQueryFilter = Nothing

    Dim pCursor As ICursor: Set pCursor = pTable.Update(pQueryFilter, False)
    Dim pRow As IRow: Set pRow = pCursor.NextRow
    Do Until pRow Is Nothing
        pRow.value(pRow.fields.FindField(field)) = value
        pRow.Store
        Set pRow = pCursor.NextRow
    Loop

End Sub

I get "Automation Error" at "Set pCursor = pTable.Update(pQueryFilter, False)" Why?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

I found it

Just change

pTable.Update(pQueryFilter, False)

to

pTable.Search(pQueryFilter, False)

and it works

share|improve this answer
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.