Parameters
- rowBuffer
- A RowBuffer with the field values to be set for the new row.
Return Value
A populated Row.
| Exception | Description |
|---|---|
| System.ArgumentNullException | rowBuffer is null. |
| System.NotSupportedException | This table/feature class does not support this operation. For example, it is a joined table. |
| ArcGIS.Core.Data.Exceptions.GeodatabaseException | A geodatabase-related exception has occurred. |
{
await QueuedTask.Run(() =>
{
string message = String.Empty;
bool creationResult = false;
EditOperation editOperation = new EditOperation();
using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde"))))
using (Table enterpriseTable = geodatabase.OpenDataset<Table>("LocalGovernment.GDB.piCIPCost"))
{
// Declare the callback here. We are not executing it .yet.
editOperation.Callback(context =>
{
TableDefinition tableDefinition = enterpriseTable.GetDefinition();
int assetNameIndex = tableDefinition.FindField("ASSETNA");
using (RowBuffer rowBuffer = enterpriseTable.CreateRowBuffer())
{
// Either the field index or the field name can be used in the indexer.
rowBuffer[assetNameIndex] = "wMain";
rowBuffer["COST"] = 700;
rowBuffer["ACTION"] = "Open Cut";
// subtype value for "Abandon".
rowBuffer[tableDefinition.GetSubtypeField()] = 3;
using (Row row = enterpriseTable.CreateRow(rowBuffer))
{
// To Indicate that the attribute table has to be updated.
context.Invalidate(row);
}
}
}, enterpriseTable);
try
{
creationResult = editOperation.Execute();
if (!creationResult) message = editOperation.ErrorMessage;
}
catch (GeodatabaseException exObj)
{
message = exObj.Message;
}
}
if (!string.IsNullOrEmpty(message))
{
Debug.WriteLine(message);
}
});
}
{
// Must be called within QueuedTask.Run
void WriteBlobField(Table table, string blobFieldName, string imageFileName)
{
// Read the image file into a MemoryStream
MemoryStream memoryStream = new MemoryStream();
using (FileStream imageFile = new FileStream(imageFileName, FileMode.Open, FileAccess.Read))
{
imageFile.CopyTo(memoryStream);
}
// Create a new row in the table, and write the Memory Stream into a blob fiele
using (RowBuffer rowBuffer = table.CreateRowBuffer())
{
rowBuffer[blobFieldName] = memoryStream;
table.CreateRow(rowBuffer).Dispose();
}
}
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)