Showing posts with label class. Show all posts
Showing posts with label class. Show all posts

Sunday, March 11, 2012

Adding Reference to App_Code of current website

I know it's possible to add a reference to a report to a custom class, but I was wondering if it was possible to refer to the code in the App_Code directory of the current website?

We have a lot of built in functionality that I could take advantage of, if I can make a call to the classes in the current site. If I have to create a new class, there's a lot of things that would have to be duplicated to get it to work and we definately don't want to have to duplicate efforts.

TIA

Well, you can reference custom assemblies from within your reports (it could be private or signed ones)

herehttp://msdn2.microsoft.com/en-us/library/aa179513(SQL.80).aspx you gonna find all you need to do so.

Hope this helps

Sunday, February 12, 2012

Adding assembly file to AS database via AMO

I am trying to add an assembly reference to an AS database using AMO objects. The class Microsoft.AnalysisServices.Assembly class does not expose any file property or source property to assign the assembly file path.

With SQL Management Studio, I can right click on the Assembly folder and add a new assembly. I want to do the same thing in code. Can someone provide me with an example? Thanks!!

The AmoAdventureWorks sample that is shipped with SQL Server has the following C# routine which does what you want.

static void CreateStoredProcedures(Database db)
{
// Create the CLR assembly
ClrAssembly clrAssembly = db.Assemblies.Add("StoredProcedures");
clrAssembly.ImpersonationInfo = new ImpersonationInfo(
ImpersonationMode.ImpersonateServiceAccount);
clrAssembly.PermissionSet = PermissionSet.Unrestricted;

// Load the assembly files
clrAssembly.LoadFiles(Environment.CurrentDirectory
+ @."\StoredProcedures.dll", false);

clrAssembly.Update();
}

|||Thanks. MSDN AMO objects tutorial only mentioned Assembly class and not ClrAssembly. Thanks again.

Adding an Image

Hello:

I have an Image control on my report .

I have a Class for example :

public Class Class1

private _MyPic as System.Drawing.Image

public property MyPic as System.Drawing.Image

......

end

end

the Dataset Of My Report is Class1.

i Drop an Image from toolbar in My Report and set Source to Database and set value to =Fields!MyPic.value

befor showing the Report i Create an object from Class1 and fill MyPic and set DataSet of Report to that Object

but i see a Red X instead of Picture

please help me

thanks alot

Setting the image source = Database is correct, but you have to convert the System.Drawing.Image into the actual image data as byte array.

Here is a C# code snippet to convert an image into a byte[] using a MemoryStream:

// save image to byte[]
System.IO.MemoryStream renderedImage = new MemoryStream();
myImage.Save(renderedImage);
renderedImage.Position = 0;
return renderedImage.ToArray();

-- Robert