tags:

views:

16

answers:

1

I am trying to modify the Maxsize of an sql 2008 Datafile, but the change does not happend.

I`m using this code:

FileGroupCollection fcoll = database.FileGroups;
foreach (FileGroup grp in fcoll)
{
    foreach (DataFile fil in grp.Files)
    {
        fil.MaxSize = 1000;
    }
}

I get no error message, but the max size of the DataFile does not change.

Any suggestions to what I`m doing wrong? Thanx.

A: 

You need to call the Alter() method.

FileGroupCollection fcoll = database.FileGroups;
foreach (FileGroup grp in fcoll)
{
    foreach (DataFile fil in grp.Files)
    {
        fil.MaxSize = 1000;
        fil.Alter(); //<---- add this!
    }
}
RedFilter