AccessProviderSample.AccessDBProvider.ClearContent C# (CSharp) Метод

ClearContent() публичный Метод

Clear the contents at the specified location. In this case, clearing the item amounts to clearing a row
public ClearContent ( string path ) : void
path string The path to the content to clear.
Результат void
        public void ClearContent(string path)
        {
            string tableName;
            int rowNumber;

            PathType type = GetNamesFromPath(path, out tableName, out rowNumber);

            if (type != PathType.Table)
            {
                WriteError(new ErrorRecord(
                    new InvalidOperationException("Operation not supported. Content can be cleared only for table"),
                        "NotValidRow", ErrorCategory.InvalidArgument,
                            path));
                return;
            }

            OdbcDataAdapter da = GetAdapterForTable(tableName);

            if (da == null)
            {
                return;
            }

            DataSet ds = GetDataSetForTable(da, tableName);
            DataTable table = GetDataTable(ds, tableName);

            // Clear contents at the specified location
            for (int i = 0; i < table.Rows.Count; i++)
            {
                table.Rows[i].Delete();
            }

            if (ShouldProcess(path, "ClearContent"))
            {
                da.Update(ds, tableName);
            }
        }