Showing posts with label groups. Show all posts
Showing posts with label groups. Show all posts

Sunday, March 25, 2012

Backing up database file groups with SMO

Hi,

I am trying to backup file groups with Backup class:

Server svr = new Server();
Backup bkp = new Backup();
bkp.Database = "AdventureWorks";
bkp.Action = BackupActionType.Files;
bkp.DatabaseFileGroups.Add("WorkOrderGroup");
bkp.DeviceType = DeviceType.File;
bkp.Devices.Add(@."c:\SMOTest_FG.bak");
bkp.SqlBackup(svr);

Unfortunately, BackupRestoreBase.DatabaseFileGroups property does not have set method (i.e. it is read-only). How can I perform a database file group backup?

Thanks in advance,

Mark

Hi Mark,

BackupRestoreBase.DatabaseFileGroups does not have a set method, but you can add DatabaseFileGroups using the Add method and that seems to work. Here is a sample application you can use (I am creating a new database, you can use an existing one) -

Server svr = new Server(".");
Database db = new Database(svr, "sampleDB");
db.Create();
FileGroup fg = new FileGroup(db, "fg1");
fg.Create();
Backup bkp = new Backup();
bkp.Database = db.Name;
bkp.Action = BackupActionType.Files;
bkp.DatabaseFileGroups.Add(db.FileGroups[0].Name);
bkp.DatabaseFileGroups.Add(db.FileGroups[1].Name);
bkp.Devices.Add(new BackupDeviceItem(@."c:\testbackup\sampleDb.bak", DeviceType.File));
bkp.SqlBackup(svr);

Thanks,
Kuntal

|||

Thanks! It worked.

In C++, I had to do the following:

Backup ^ bkpH = gcnew Backup();

bkpH->Database = gcnew String(dbName);

bkpH->Action = BackupActionType::Files;

StringCollection^ strCollH = bkpH->DatabaseFileGroups;

strCollH->Add(gcnew String(groupName));

...

Backing up database file groups with SMO

Hi,

I am trying to backup file groups with Backup class:

Server svr = new Server();
Backup bkp = new Backup();
bkp.Database = "AdventureWorks";
bkp.Action = BackupActionType.Files;
bkp.DatabaseFileGroups.Add("WorkOrderGroup");
bkp.DeviceType = DeviceType.File;
bkp.Devices.Add(@."c:\SMOTest_FG.bak");
bkp.SqlBackup(svr);

Unfortunately, BackupRestoreBase.DatabaseFileGroups property does not have set method (i.e. it is read-only). How can I perform a database file group backup?

Thanks in advance,

Mark

Hi Mark,

BackupRestoreBase.DatabaseFileGroups does not have a set method, but you can add DatabaseFileGroups using the Add method and that seems to work. Here is a sample application you can use (I am creating a new database, you can use an existing one) -

Server svr = new Server(".");
Database db = new Database(svr, "sampleDB");
db.Create();
FileGroup fg = new FileGroup(db, "fg1");
fg.Create();
Backup bkp = new Backup();
bkp.Database = db.Name;
bkp.Action = BackupActionType.Files;
bkp.DatabaseFileGroups.Add(db.FileGroups[0].Name);
bkp.DatabaseFileGroups.Add(db.FileGroups[1].Name);
bkp.Devices.Add(new BackupDeviceItem(@."c:\testbackup\sampleDb.bak", DeviceType.File));
bkp.SqlBackup(svr);

Thanks,
Kuntal

|||

Thanks! It worked.

In C++, I had to do the following:

Backup ^ bkpH = gcnew Backup();

bkpH->Database = gcnew String(dbName);

bkpH->Action = BackupActionType::Files;

StringCollection^ strCollH = bkpH->DatabaseFileGroups;

strCollH->Add(gcnew String(groupName));

...

Tuesday, March 20, 2012

backgroundcolor in groups

Hello,
There are 3 groups in my table. The second and third group are hidden and
can be drilled down. I have a code to set alternate color for backgroundcolor
of each rows (the first group). The code is "= iif(RunningValue(
Fields!uniqueID.Value, CountDistinct, Nothing) mod 2, "white", "yellow")".
However, some rows can not return alternate color. The report looks like that:
row1 (backgroundcolor is white)
row2 (backgroundcolor is yellow)
row3 (backgroundcolor is white)
row4 (backgroundcolor is white)
row5 (backgroundcolor is yellow)
Does anybody know how to set alternate color for groups?
Thanks!The RunningValue runs based on the details, but you are using the value to
determine the color of groups. If one group contains an even number of
details, the next group will have the same backgroundcolor as the previous
group.
At this point, there is no predefined aggregate function available that
would just count the groups. However, you may want to read this article
which explains the steps necessary to get this working:
http://blogs.msdn.com/chrishays/archive/2004/08/30/223068.aspx
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Jean" <Jean@.discussions.microsoft.com> wrote in message
news:C44CDF74-4505-47C7-B7EB-F53F788698EF@.microsoft.com...
> Hello,
> There are 3 groups in my table. The second and third group are hidden and
> can be drilled down. I have a code to set alternate color for
backgroundcolor
> of each rows (the first group). The code is "= iif(RunningValue(
> Fields!uniqueID.Value, CountDistinct, Nothing) mod 2, "white", "yellow")".
> However, some rows can not return alternate color. The report looks like
that:
> row1 (backgroundcolor is white)
> row2 (backgroundcolor is yellow)
> row3 (backgroundcolor is white)
> row4 (backgroundcolor is white)
> row5 (backgroundcolor is yellow)
> Does anybody know how to set alternate color for groups?
> Thanks!
>
>|||Thanks for your help! It works after I change my code to
"= iif(RunningValue(Fields!uniqueID.Value & Fields!group1.Value,
CountDistinct, Nothing) mod 2, "white", "yellow")".
Jean
"Robert Bruckner [MSFT]" wrote:
> The RunningValue runs based on the details, but you are using the value to
> determine the color of groups. If one group contains an even number of
> details, the next group will have the same backgroundcolor as the previous
> group.
> At this point, there is no predefined aggregate function available that
> would just count the groups. However, you may want to read this article
> which explains the steps necessary to get this working:
> http://blogs.msdn.com/chrishays/archive/2004/08/30/223068.aspx
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "Jean" <Jean@.discussions.microsoft.com> wrote in message
> news:C44CDF74-4505-47C7-B7EB-F53F788698EF@.microsoft.com...
> > Hello,
> >
> > There are 3 groups in my table. The second and third group are hidden and
> > can be drilled down. I have a code to set alternate color for
> backgroundcolor
> > of each rows (the first group). The code is "= iif(RunningValue(
> > Fields!uniqueID.Value, CountDistinct, Nothing) mod 2, "white", "yellow")".
> > However, some rows can not return alternate color. The report looks like
> that:
> >
> > row1 (backgroundcolor is white)
> > row2 (backgroundcolor is yellow)
> > row3 (backgroundcolor is white)
> > row4 (backgroundcolor is white)
> > row5 (backgroundcolor is yellow)
> >
> > Does anybody know how to set alternate color for groups?
> >
> > Thanks!
> >
> >
> >
> >
>
>sql

Background color for each first row in groups

I have a report that groups on departments. I want the first row for each
group to be light gray, while the row below it are white. Any suggestions?
ThanksIt has been a little while since you posted this question, but I think I have
an answer I discovered while researching a solution to one of my problems.
The RowNumber aggregate function might be helpful to you. Try the following
somewhere in your report to verify this will help:
RowNumber("group_name")
Try concatinating that to a text field on the row you want the coloring to
ultimately be on; I believe you will find that the first record in each group
has a 1. Presuming it does give you a 1 where you want it to be, all you
need to do then is select the row in question, and place the following
expression in the Background Color field (or any othr formatting field, like
Font Weight or Font Style):
=IIF( RowNumber("group_name") = 1 , "Light Gray" , "White" )
"PatNUFC" wrote:
> I have a report that groups on departments. I want the first row for each
> group to be light gray, while the row below it are white. Any suggestions?
> Thanks

Thursday, February 16, 2012

Averages by groups? VB.Net 2005 & Crystal

I fixed my previous problem, but have since ran across this.

My report looks something like this:

Location #1
ID1 ItemsSold TotalPay
ID2 ItemsSold TotalPay
ID3 ItemsSold TotalPay
*** SummedItemsSold SummedPayForGroup
Location #2
ID1 ItemsSold TotalPay
ID2 ItemsSold TotalPay
ID3 ItemsSold TotalPay
*** SummedItemsSold SummedPayForGroup

GrandTotal *** GrandItemsSold GrandTotalPay

I am figuring the GrandTotal fine...it's the lines with the sums of ONLY the group items that I am having problems with. They reside in the Group Footer Section 1 area of the report. Any help on how to total them correctly?Is it giving a grand total for the group totals

how is the groups totals incorrect.|||The grand total is giving the sum of all items and a sum of all pay. Those are the correct numbers I am wanting to show. The footer sums are only showing the pay total for one record(the maximum pay record). I tried using a running total, but I am not sure which to use.|||I was able to set up a CR that displays

Group Header (Location)
Details (value)
Group Footer Total of (value) per location
GrandTotal

I did this for the footers the same as I did for the GrandTotal.

when I selected the sum tool button I then changed the Summary location to group #1
this created a field for the group footer to total the value per group.|||I am able to get to where you are up until the point where I pick the field to summarize. The calculations to summarize by are:

Max
Min
Count
Distinct Count
Mode
Nth Largest
Nth Smallest
Nth Most Frequent

I am wanting it to add the totals for the group, and i am not seeing that as available. What am I doing wrong?|||This is something with the type of field you are trying to sum.
I went in to my example and changed my value field to a date field or a string field and it only gave me the options that you show.