Select to view content in your preferred language

Inserting Multiple Rows into Table

3165
17
Jump to solution
01-28-2013 11:06 AM
JoshObrecht
Regular Contributor
I am trying to insert multiple rows into a Geodatabase table through VB, but for some reason the program crashes when trying to enter a new row when the table already contains a row. I'm not sure if there is a lock that is occurring or what is going on. I have tried using both cursors and IFeature.store. Has this occurred for anybody else and how were you able to solve it?
0 Kudos
17 Replies
JoshObrecht
Regular Contributor
feature is declared at Dim feature As IRowBuffer.

And I can't move the OpenTable out as it is dependent on shape being equal to the feature's aliasname.
0 Kudos
JeffMatson
Frequent Contributor
feature is declared at Dim feature As IRowBuffer.

And I can't move the OpenTable out as it is dependent on shape being equal to the feature's aliasname.


Do you mean to be calling .Insert or .InsertRow on this line?

tableInsertCursor = outputSignDetailTable.InsertRow(True)


Also it looks like your string variable shape is set already to ArcMapAddin1.ArcGISAddin1.val, is it changing some other way so that you might be processing more than one type at a time? 

shape = ArcMapAddin1.ArcGISAddin1.val
'...
'...
'...
'...
Do While pFeat IsNot Nothing
       If shape = pFeat.Class.AliasName Then
           outputSignDetailTable = DirectCast(workspace, IFeatureWorkspace).OpenTable(shape)
           tableBuffer = outputSignDetailTable.CreateRowBuffer()
           row = CType(tableBuffer, IRow)  '<-- is this used anywhere else?
           feature = tableBuffer  '<--- why not just use the tableBuffer object?
0 Kudos
JoshObrecht
Regular Contributor
Good call on using shape in the table. Not sure why I didn't catch that. However, that's not the cause.

And I only used the following code as I saw someone else on here using it. I was trying to originally use CreateRow with some different code but it errored as well.

tableBuffer = outputSignDetailTable.CreateRowBuffer()
           row = CType(tableBuffer, IRow)  
           feature = tableBuffer
0 Kudos
JeffMatson
Frequent Contributor
Good call on using shape in the table. Not sure why I didn't catch that. However, that's not the cause.

And I only used the following code as I saw someone else on here using it. I was trying to originally use CreateRow with some different code but it errored as well.

tableBuffer = outputSignDetailTable.CreateRowBuffer()
           row = CType(tableBuffer, IRow)  
           feature = tableBuffer




If you step through your code one line at a time, on which line does the error occur?  I'm still confused how tableInsertCursor = outputSignDetailTable.InsertRow(True) would not cause a problem.
0 Kudos
JoshObrecht
Regular Contributor
After testing it, that is in fact where the error is occurring now. Before it was occurring on the insert portion.
0 Kudos
JoshObrecht
Regular Contributor
The error is occurring at tableInsertCursor = outputSignDetailTable.InsertRow(True).
0 Kudos
JeffMatson
Frequent Contributor
What happens when you try it using .Insert instead of .InsertRow?

The error is occurring at tableInsertCursor = outputSignDetailTable.InsertRow(True).
0 Kudos
JoshObrecht
Regular Contributor
That solved that issue. There was another error that was provided but I was able to resolve that. Thanks!
0 Kudos