How to display text/image in a report depending on buildoption? - reporting-services

I would like to display a text or an image on my reports depending on buildoption, ie debug/release so my users are never confused about what environment they are in.
I work in visual studio 2013. Is it possible to use app.config or something similiar for reports?

Ok, worked this one out for myself, sort of.
I added a background image and used expression (Globals!ReportFolder) if I should display it or not.
Expression was: =IIF((Globals!ReportFolder = "/Test"), "TestBackground", "")
Thanks to Sébastien Sevrin for pointing out that reports arent built and I need to look into deploysettings.

Related

SSRS - Accessing System.Drawing.Image.FromStream

I am currently trying to center an image on screen in SSRS. While this functionality is not directly support it is possible to provide custom padding based on the image size. This is an external image provided by a database, so the image changes repeatedly and I cannot hard code a padding. I am trying to retrieve the width of the image using:
=System.Drawing.Image.FromStream(new System.IO.MemoryStream(CType(System.Convert.FromBase64String(Fields!HomeLogoImage.Value), Byte()))).Width
However when this is entered into an expression place holder, "FromStream" is not recognised.
I can confirm that I have added the reference to the system.drawing assembly and I am using version 4.0.0.0.
I am returning to SSRS for the first time in quite a while so any advice on this would be greatfully received. Or even if there is a way to center images without resorting to the System.Drawing method, I would love to hear.
Many thanks.
Try the following. I've tested this against some .png database images I had lying around and it seemed to work.
=System.Drawing.Image.FromStream
(new System.IO.MemoryStream(CType(Fields!Image.Value,Byte())))
.Width
EDIT after OP update
To do the same with an external image you can use the following
=System.Drawing.Image.FromStream
(new System.IO.FileStream(Fields!HomeLogoImage.Value, IO.FileMode.Open))
.Width
This assumes that the HomeLogoImage field contains a valid path and filename to the image.
However You will probably encounter a permissions error. I have not done this myself so I can only point you to a link that discusses the issue with possible solutions. I've not done anything other than a quick search to find this so better solutions may be available
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/31490332-c2f7-48a4-9928-29916ce002b4/request-for-the-permission-of-type-systemsecuritypermissionssecuritypermission-mscorlib?forum=sqlreportingservices

SSRS - embed URL and formatting characters in parameter

I'm making a form letter in SSRS 2012 that will be delivered by email. I had it working fine but now the powers that be have requested a much more dynamic aspect to it based on the individual recipient... Different paragraphs now need to be included/excluded based on the target.
With that, I pulled the body of the email out of SSRS and am now assembling it in SQL Server and passing it over to SSRS as a parameter (so that I don't wind up making a dozen SSRS reports to handle the need).
I have that part working too now, but hit a snag... There were a few bullet points as well as URL's that could look nicer. I'd like to force an indention before the bullet points and replace www.mysite.com with something prettier like "Click Here". On the SSRS side of the fence, I currently just have a single text box (and ideally would keep it that way) which contains an expression that references my "EmailBody" parameter.
So far, I have not found the right combination of words to send to Google to see if this is possible, so I figured I'd go straight to the pros here. I did try formatting the output in a similar manner to what an expression would look like ( ="This is the body of my email" ) and it just passed that straight on through to the final output.
Any ideas would be appreciated!
Jason
In case it helps anyone else, I figured out the secret.
Change your text box in SSRS to expect HTML by right-clicking on the placeholder (<< EXP >>) inside the text box, selecting Placeholder Properties, and change the Markup Type to "HTML - Interpret HTML tags as styles".
After that, go back to the SQL Server side of the fence and change the text you are sending as a parameter to HTML with whatever styling properties you desire.
Sounds like you're on the right track with the HTML markup. I also wanted to suggest that you can use a data-driven subscription. Have the query generate the HTML you want. Then have that populate the body of the email. That way there's no need for any attachments. This has come in handy when I wanted to display a small table of data for viewing on a mobile device rather than having to open an Excel attachment.

Use a Visio PageName as an Email Subject

I hate to do this, but I have the same question as the following link: Visio 2010 using a page name in mailto link
I have attempted to use the answer given but all I'm getting is PAGENAME() in the subject field of the generated email. My Visio file is rendered to a html file where this link will be used.
I'd have added a comment to avoid creating a new question but don't have enough Rep to follow up on the comments there.
If anyone can give me a pointer, that'd be great. The line I have at the moment is
>
mailto:my.email#email.com&Subject=PAGENAME()&Body=Text...
Okay, looks like I've worked this one out.
I needed to right click the object & head in to the "Show ShapeSheets" window.
Once in here, adjust the 'Hyperlinks' entry: In the 'ExtraInfo' box change:
="subject=PAGENAME()"
to
="subject="&PAGENAME()
Logical when you look at it.
I do have the problem now that when Visio renders the html files, it doesn't use the foreground PAGENAME() in the same way was when you insert PAGENAME() into an object. The email title is always the background name & not the foreground.
I doubt there'll be a way of resolving that one, but glad I got to see it in action.

Footer not hiding when export to MS Word

I only want to display the footer (which has some texts) in the first page of my SSRS report. So I code the following in Expression to hide:
=IIF(Globals!PageNumber = 1, false, true)
However, when I export to MS Word via SSRS, I get the footer in every single page (it works perfectly fine in PDF).
This seems to be a known problem according to:
http://msdn.microsoft.com/en-us/library/dd283105(v=sql.105).aspx#ReportHeadersFooters
And the document provided a workaround using "Expression with Text Runs".
I have been trying to figure out what that means and how to apply that but have been struggling for a while.
Does anyone know a work-around for this problem?
Thanks!
This answer is pretty late in coming to this user, but for any others fighting with this, please see the msdn SQL Server export to Word write-up here:
http://msdn.microsoft.com/en-us/library/cc627455(v=SQL.100).aspx
In a nutshell, toggling states anywhere in the report is not supported. Whatever the state of the report item is on the first page is what it'll be throughout the exported report. With that in mind, it appears that PDF will be a better format to support with your customers.

Is there a way to get ms-access to display images from external files

I've got an MS-Access app (1/10th MS-Acccess, 9/10ths MS-SQL) that needs to display photographs of some assets along with their specifications. Currently the images are stored in an MS-Access table as an OLE Object (and copy-n-pasted into the field by the users).
For various reasons, I would like to do is store the original .jpgs in a folder on the network drive, and reference them from the application portion. I have considered moving into MS-SQL's image data type (and its replacement varbinary), but I think my user population will more easily grasp the concept of the network folder.
How can I get MS Access to display the contents of a .jpg?
Another option is to put an image control on your form. There is a property of that control (Picture) that is simply the path to the image. Here is a short example in VBA of how you might use it.
txtPhoto would be a text box bound to the database field with the path to the image
imgPicture is the image control
The example is a click event for a button that would advance to the next record.
Private Sub cmdNextClick()
DoCmd.GoToRecord , , acNext
txtPhoto.SetFocus
imgPicture.Picture = txtPhoto.Text
Exit Sub
End Sub
Have you looked at Stephen Lebans' solutions? Here's one:
Image Class Module for Access
Check out the list of other great code along the left-hand side of that web page. You may find something that fully matches what you need.
I found that this article by Microsoft with full VBA worked very well for me.
How to display images from a folder in a form, a report, or a data access page
The easiest way is probably to plop an Internet Explorer onto one of your forms. Check out this site: http://www.acky.net/tutorials/vb/wbrowser/
Since you can reference that object in Access, you will only need to point the webbrowser control to the path of the .jpg (NavigateTo() if I remember correctly).
EDIT: The above link was just googled and picked from the results (first one that opened quickly). I do not think it is a very good tutorial, it just has all the pointers you need... Check out msdn etc. if you need more information!
You can try an ActiveX control called AccessImagine, makes adding images to database more convenient - you can load from file, scan, paste from buffer or drag-n-drop. You can crop image right inside the database and resample it automatically. It handles external image storage automatically if you need it.
Note that in Access 2010 (and later) this is dead simple to do because the Image control can be bound to a field in the table that contains the path to the image file (.jpg, .png, ...). No VBA required.
For more details see my other answer here.
Do you mean something like this?
Display images in MS-Access Form tabular view.
Here's the original post from microsoft:
https://learn.microsoft.com/en-us/office/troubleshoot/access/display-images-using-custom-function
You just need to modify something in the form events:
Modify this part of the form code
Image Control
Name: ImageFrame
Picture: "C:\Windows\Zapotec.bmp"
Control Source: txtImageName
Note that the Control Source named "txtImageName" is the field name in your table which has the name and path of your images.
Everything get's fine after you modify that part.