ssrs url path string manipulation - reporting-services

I have a url string that I'm getting from the DB for a file in my sharepoint server e.g.
http://mysharepointserver.com/abc/def.jpg
and I would like to get the url path e.g. http://mysharepointserver.com/abc removing the file name. Can someone please give me an example on how this can be done in SSRS? I'm using SSRS 2012 but I'm fairly new to SSRS.
Any help greatly appreciated.
Vince.

You could write some custom code on the report. There is a Code property on the report itself where you can write VB functions. One similar to this should do the job.
Function GetPath(ByVal FullPath As String) As String
Return System.IO.Path.GetDirectoryName(FullPath)
End Function
Then in the expression on a Textbox you can call the function.
=Code.GetPath("http://mysharepointserver.com/abc/def.jpg")
For more detailed step by step instructions try http://msdn.microsoft.com/en-us/library/ms156028.aspx

Related

JRDataset property CSV file

I have a build up a report with a .CSV input file as DataAdapter. After that I needeed a table to put some data into a it and a linked dataset. The problem is: if I leave blank the section "Default Data Adapter" in my Dataset1, no data will be displayed. In fact, to fix this report I had to export my DataAdapter as myDataAdapter.xml and then put this file in the section "Default Data Adapter" of my Dataset1 (as shown in the attached picture).
Working with database I have never set up this property.
Is there a way to pass this property as Param? (I have a java code in which I call jasperReport and I want to pass this object dinamically).
Or is there a way the report works without setting this property?
In the section Table>Dataset I have this situation:
where I set up JRDatasource expression, but it is not working...
I have one more problem. Can I set dinamically the location of my .csv inside the DataAdapter.xml?
Is it possible to implement "myDataAdapter.xml" from java code and pass it to the report??
Thank you in advance!
In Java code you can set properties on the net.sf.jasperreports.engine.JasperReport instance like in this sample here, from the official repository. The relevant code looks like this:
...
JasperReport jasperReport = ...
...
jasperReport = (JasperReport)JRLoader.loadObjectFromFile("build/reports/ExcelXlsxQeDataAdapterReport.jasper");
jasperReport.setProperty(DataAdapterParameterContributorFactory.PROPERTY_DATA_ADAPTER_LOCATION, "data/XlsxQeDataAdapter.xml");
...
The property of interest is net.sf.jasperreports.data.adapter and is stored in DataAdapterParameterContributorFactory.PROPERTY_DATA_ADAPTER_LOCATION
The data adapter file is a convenience method to pass a series of parameters from which a net.sf.jasperreports.engine.data.JRCsvDataSource is built. If you want to skip passing this property, you would have to manually provide the built-in parameters listed in the net.sf.jasperreports.engine.query.JRCsvQueryExecuterFactory.CSV_BUILTIN_PARAMETERS.

Isolate values in a comma delimited field using SSIS

I've been working in SSIS trying to parse a multi-valued excel spreadsheet field using VB.Net. My script works by searching for a comma, then using string functions (Left, Right) to whittle down the string until it's null.
Is there an SSIS toolbox function that will do that for me? If so, please tell me :)
Using Visual Studio 2019, Excel 2016.
I personally use c# script component for this.
string textToSplit = Row.[Your Column].Value;
string[] splits = textToSplit.Split(',');
//Now you can work with all sections
foreach(string split in splits)
{
//This is where you do something with each part
}
If the strings are quote wrapped or have commas inside the pieces then you have to use a more complicated splitter utilizing REGEX.
Well, I think I figured it out - it's to use the derived column transformation within the data flow task. With it I can use LEFT and RIGHT functions to parse. I appreciate the help with the C# code - my VB.Net code is very similar. Going to test on Monday!

Access-VBA - Compile Error with ConcatRelated - Previously worked

I'm receiving a compile error attempting to run a query using Allen Browne's ConcatRelated function.
Compile error: in query expression 'SELECT MbrNbr, EventIndex, ConcatRelated("EventIndex", "PlayerResults", MbrNbr = 123456)'.
The mystery is I know this executed successfully previously.
Note: This is my first time using MS Access for a project, so it's my first time using Allen's ConcatRelated function. I have to assume there is something obvious I'm missing. I've coded in MS Excel VBA for about 10 years.
I do have a query that is more complex than the example below but I put together this very basic query just to test if there is something amiss with my setup all of a sudden.
I've googled all I can to attempt to resolve this and all code examples seem to show I have it correct.
Setup:
ConcatRelated is saved as a function named Concat_Related_Data. I've read the function name cannot be ConcatRelated.
The simple query receiving the error is:
SELECT MbrNbr, EventIndex, ConcatRelated("EventIndex", "PlayerResults", MbrNbr = 123456)
FROM PlayerResults;
Note: I copied Allen's example and simply edited it with a call to one of my tables. Field MbrNbr is defined as "Number".
Any insights would be greatly appreciated!
After taking a look here http://allenbrowne.com/func-concat.html I saw that the third parameter is defined as a string parameter too (as expected) and not as a boolean.
So I think you should use this:
SELECT MbrNbr, EventIndex, ConcatRelated("EventIndex", "PlayerResults", "MbrNbr = 123456") FROM PlayerResults;
Info: The third parameter of ConcatRelated also is a string here, containing your condition.
In addition to the answer provided by #UnhandledException; where you state:
ConcatRelated is saved as a function named Concat_Related_Data.
I've read the function name cannot be ConcatRelated.
For clarity: the code for the function should be copied "as is" from Allen Browne's site into a new VBA module, without changing the function name.
However, when saving the VBA module, the module should be named something different to ConcatRelated, else you will receive a type-mismatch error when trying to invoke the function.
Note that if you are using the code within SQL code that is represented using a string in VBA, you will need to either escape the double-quotes (to ensure that they remain in the SQL code), or use single-quotes instead, i.e.:
CurrentDb.OpenRecordset("SELECT MbrNbr, EventIndex, ConcatRelated('EventIndex', 'PlayerResults', 'MbrNbr = 123456') FROM PlayerResults")
Or:
CurrentDb.OpenRecordset("SELECT MbrNbr, EventIndex, ConcatRelated('EventIndex', 'PlayerResults', 'MbrNbr = 123456') FROM PlayerResults")

Current Field Value into a VBA String Programmatically

I need to take the current value of a field from the record displayed on an open Access form and put the text in that field into a VBA string programmatically. This seems so simple but I have not yet been to find any guidance from either an aftermarket Access 2013 text I purchased or the Internet. I have tried everything I can think of with no success whatsoever so I posted a question on stackoverflow.com and received the following suggested solution:
Dim strYourString as String
strYourString = Forms![Your Form Name].[Field Name].Value
When this is run I get:
Runtime error ‘438’
Object doesn’t support this property or method
Any help will be greatly appreciated!
Try using a bang symbol in front of the field name, instead of a period.
strYourString = Forms![Your Form Name]![Field Name].Value
^---------------------Bang symbol here
This is supported by the documentation here on MSDN. Note the implicit form:
Forms!OrderForm!NewData
where NewData is the name of a control. Or you can use an explicit reference:
Forms!OrderForm.Controls!NewData
If you want to refer to a field in the underlying recordset of the form instead, use:
Forms!MyForm.Recordset.Fields("MyFieldName")

Custom code in Reporting Services report

In Reporting Services I would like to add a parameter that contains data from a custom code block. Ideally, I would be able to run the following code (this is a simple testing example):
Function GetPeriods() As String()
Dim values As System.Collections.ArrayList =
New System.Collections.ArrayList()
For i as integer = 1 to 24
values.Add(i)
Next
Return values.ToArray()
End Function
and put the following in the "Text Field" of the parameter:
=Code.GetPeriods()
However, when I run the report, the parameter I apply this to is disabled and empty. Is there a different technique that should be used? Or am I doing something wrong?
If you're using SQL 2008 Reporting Services then you can have a look at this page which introduces the concept of using custom assemblies.
If you're using SQL 2005 Reporting Services then this link is the one you want.
It's a mostly trivial thing, simply compile your code into a class library and follow the instructions provided to allow your report to reference it.
You are returning an array item (an array of strings) into a text field. Instead, try returning a plain string. That should work. If you would still like to return an array list, you must basically bind it to a list control in your RDL. You can definitely do that with dataset extensions. However, I am not sure if there is any other easy way. Check the proprties of the list control and see if it allows you to directly bind to an array list.
You can create the same stored procedure on SQL Server and load parameter values from that procedure.
To access your members/functions implemented in custom code of SSRS report you should set the access modifier to "Public":
Public Function GetPeriods() As String
...
see article Writing Custom Code in SQL Server Reporting Services
I've been trying to do this same thing, set a simple list of parameter values from report code. None of the links in any of these answers shows how to do this and after quite a bit of digging around I don't think it's even possible. Yes it is possible to get the values from a database query, from a web service, or from a custom assembly, but each of these creates a lot of overhead compared to getting the list from a simple function call like =Code.GetValues(), where the function uses a For loop to create the values.
msvcyc is correct in pointing out that the parameter is expecting a string value, but the function is returning an array. I changed the return type to Array as suggested by prashant sable, but the select list is still grayed out, it does not work. And coldice is correct in saying that the access modifier should be Public.
In my digging around I found an article by James Kovac from 2005 that pointed out why this is not possible. The Parameters class has a get method, but no set method. In the VS 2008 object browser for SSRS 2008 the object name has changed, but it still does not contain a set method (see Microsoft.ReportingServices.Interfaces.IParameter.Name or .Value).
My current workaround is to just hard code the list of values, but if your value list needs to be dynamic then your only choices are database queries, web services, or custom assemblies. I think the easiest workaround of these three is to get the values from the database engine, as suggested by oleksiy.t, as long as you can write a query to return the value list you want. Your list of integers, or my list of time intervals, would both be easy queries to write. Otherwise you will need to use one of the other two workarounds.
I checked your code. The only thing that's wrong is your function returns String(). When I changed your method signature to return Array, it worked fine, in my report.
Change the signature to Function GetPeriods() As Array
Everything I've seen requires parameters and their respective settings to be part of the RDL.
That being said, if you're going to "hardcode" the values, you could create a dataset just for the report, perhaps in XML, or if it needs to be programmatically driven, do it in a web service.