I have a small software that connects to a database (SQLServer) reads a few values and transfers them to a SDE Oracle instance (11g).
The problem is: I have over half million records that I need to transfer. My code reaches for the records without an issue, but when I try to insert...(my guess is that you guys already got throught this) I get a lovely COM error, screaming at me about Single Threaded and Multi Threaded apartments.
Here is a snippet:
IFeatureWorkspace workspace = GetWorkspace() as IFeatureWorkspace;
ITable newTable = workspace.CreateTable("blevers", fields, uid, null, "");
IRowBuffer buffer = newTable.CreateRowBuffer();
ICursor cursor = newTable.Insert(false);
IMultiuserWorkspaceEdit workspaceEdit = workspace as IMultiuserWorkspaceEdit;
IWorkspaceEdit2 workspaceEdit2 = workspaceEdit as IWorkspaceEdit2;
workspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMNonVersioned);
workspaceEdit2.StartEditOperation();
for (int i = 0; i <= stringList.Count - 1; i++)
{
buffer.set_Value(0, stringList[i]);
cursor.InsertRow(buffer);
Console.WriteLine("Escrevendo linha " + i.ToString() + " de " + stringList.Count);
}
cursor.Flush();
workspaceEdit2.StopEditOperation();
workspaceEdit2.StopEditing(true);
I usually get the error inside the for loop. How can I insert big big cursors without problems?
EDIT: i've also tried using a SchemaLock, but a COM error explodes in my face when converting the ITable to ISchemaLock. I'm out of ideas!
