110,566
社区成员
发帖
与我相关
我的任务
分享
internal void InsertRow(DataRow row, int proposedID, int pos, bool fireEvent)
{
Exception deferredException = null;
bool flag;
if (row == null)
{
throw ExceptionBuilder.ArgumentNull("row");
}
if (row.Table != this)
{
throw ExceptionBuilder.RowAlreadyInOtherCollection();
}
if (row.rowID != -1)
{
throw ExceptionBuilder.RowAlreadyInTheCollection();
}
row.BeginEdit();
int tempRecord = row.tempRecord;
row.tempRecord = -1;
if (proposedID == -1)
{
proposedID = this.nextRowID;
}
if (flag = this.nextRowID <= proposedID)
{
this.nextRowID = proposedID + 1;
}
try
{
try
{
row.rowID = proposedID;
this.SetNewRecordWorker(row, tempRecord, DataRowAction.Add, false, pos, fireEvent, out deferredException);
}
catch
{
if (flag && (this.nextRowID == (proposedID + 1)))
{
this.nextRowID = proposedID;
}
row.rowID = -1;
row.tempRecord = tempRecord;
throw;
}
if (deferredException != null)
{
throw deferredException;
}
if (this.EnforceConstraints && !this.inLoad)
{
int count = this.columnCollection.Count;
for (int i = 0; i < count; i++)
{
DataColumn column = this.columnCollection[i];
if (column.Computed)
{
column.CheckColumnConstraint(row, DataRowAction.Add);
}
}
}
}
finally
{
row.ResetLastChangedColumn();
}
}
DataTable dt = new DataTable();
dt.Columns.Add("标题名");
DataRow row = dt.NewRow();
row[0] = "121";
dt.Rows.Add(row);