public void ReplaceNulls(Data.DataRow TheRow)
{
//Replace any row items containg null data with the default data for this item's data type.
for (int I = 0; I <= TheRow.Table.Columns.Count - 1; I++) {
Data.DataColumn TableColumn = TheRow.Table.Columns(I);
Type ColumnType = TableColumn.DataType;
if (object.ReferenceEquals(TheRow.Item(I), DBNull.Value)) {
if (ColumnType.FullName == "System.String") {
TheRow.Item(I) = "";
} else {
TheRow.Item(I) = Activator.CreateInstance(ColumnType);
}
}
}
}
No comments:
Post a Comment