SSRS Custom code
Can we call custom code in parent report, which written in the subreport
Thanks in advance
Can we call custom code in parent report, which written in the subreport??
Example :
i have written code in subreport as follows
This can call it on parent report as "code.EmbeddedFunction()"
Thanks in advance
Similar Messages
-
How to control or manipulate a report parameter through SSRS Custom Code
Hi,
In reporting services 2005 or 2008, is it possible to control the parameters inside the custom code of a report?
for example:
Let's say I have a parameter that displays the following value:
Red
Green
Blue
In typical scenario I can select one of the values or I can select all of the values then click the View Report button in reporting services.
I know that this approach is much easier to do if I have an external application like ASP.Net and from there I'll just add report viewer and control the parameters to be passed and then generate the report.
In the report I added text box that will serve as a hyperlink to refresh report:
In the Text Box Properties\Action tab. Is it possible to control the selection of values through a custom code(SSRS Custom Code) then the report will be automatically refreshed?
thanks,
JoeferNot sure about doing a multiple selection. But you can pop up an input box to get the input on the fly.
Add the below custom code and expression for the above parameter
Public function Getparamvalue() AS STRING
Dim x as STRING
x = InputBox("Enter Red / Blue / Green")
Return(x)
End function
=Code.Getparamvalue() -
SSRS custom code for count in Report Footer
Hi All,
Please help me with the custom code used for below requirement
Debtor Name current 30+days 60+days 90+days
aaa 7000 0.00 0.00 10.00
bbb 5000 0.00 20.99 3.00
ccc 1000 0.00 0.00 0.00
Expected result in report footer :
0 1
2
if the value of 30+ , 60+ and 90+ columns >=1 then i have to display the count in Report footer,for that i have tried using a custom code like below :
Shared Dim OD As Integer=0
Public Shared Function Test(ByVal OP As Decimal) As Integer
If OP >= 1 Then
OD = OD + 1
Else
OD = OD
End If
Return OD
End Function
and using below code to display
Code.Test(Overdue)
but when i use this code in report footer is not displaying correct value.Please guide me where i am going wrong.
Please let me know if you need any other details.
Thanks in advance,
Samhith.Hi Samhith,
Per my understanding you what to count the rows which values >=1 and display them at the bottom of the table, you are trying to use the custom code to do this but failed, right?
I have tested in my local environment and find the custom code is not correctly, and I have an alternative method which is more easy and can work in both table and matrix.
As Vaibhav Chaudhari also mentioned that we can use the CountDistinct function, but more correctly, we can use the count() function and the RunningValue() function, because CountDistict will not count the duplicated values if they >=1.
Please find the expression as below:
=Count(IIf(Fields!Yourfield.Value>=1 , Fields!Yourfield.Value, Nothing))
OR:
=RunningValue(IIf(Fields!Yourfield.Value>=1 , 1, Nothing),Sum,"DataSetName")
If you still have any problem, please feel free to ask.
Regards
Vicky Liu -
I am receiving this error with the following code, which counts the number of work days between two parameters and I don't see the problem. Please help.
Public Function GetDateCount(ByVal StartDate AS DateTime, ByVal EndDate AS DateTime) AS Integer
Dim TempVal AS Integer
DimTotalDays AS Integer
TotalDays = 0
TempVal = DateDiff(DateInterval.Day, StartDate, EndDate) + 1
for I as Integer = 1 to TempVal
If(StartDate.DayOfWeek.ToString() <> "Sunday" AND StartDate.DayOfWeek.ToString() <> "Saturday") Then
TotalDays = TotalDays +1
End If
StartDate = DateAdd(DateInterval.day, 1, StartDate)
Next
Return TotalDays
End FunctionHi CNet Vase,
According to your description, you want to use custom code to count the number of work days between two parameters in the report, but when you run the report, an error occurs.
I reproduced the issue in my environment, the error message: ‘DimTotalDays’ is not declared. The error is caused by there is no space between Dim and variable TotalDays, so the system regards it as a unit. To fix this issue, please type
space behind the word Dim like below:
Dim TotalDays AS Integer
If there is any misunderstanding , please feel free to let me know.
Best Regards,
Wendy Fu -
Hi,
I am trying to write Custom Code in SSRS for Age Calculation for two requirements in the same report,But report is giving error #Error in expression with my below code.
whole logic is same for both but only two lines are different,Do i need create two functions or can i use them in one function.Please guide me.
1)Age in Years (Ex: 4)
2) Age in Years + months (ex: 3 Years 6 months)
My SSRS Custom Code:
Public Shared Dim Years as Integer
Public Shared Dim Months as Integer
Public Shared Dim Days as Integer
Public Shared Dim Age as Integer
Public Shared Function CalAge(ByVal D1 As Datetime,ByVal D2 As Datetime ) As Integer
Years=Year(D1)-Year(D2)
Months=Month(D1)-Month(D2)
Days=Day(D1)-Day(D2)
If Days < 0 then
Months=Months-1
End if
If Months < 0 then
Years=Years-1
End if
If Months < 0 then
Months=Months+12
End If
Return Years
If Months=1 then
Age=Years+" Years " + Months + "Month"
else
Age=Years+" Years " + Months + "Months"
End If
Return Age
End Functionhi Guys,
I have finally changed my custom code to below :
Public Shared Dim Years as Integer
Public Shared Dim Months as Integer
Public Shared Dim Days as Integer
Public Shared Function CalAge(ByVal D1 As Datetime,ByVal D2 As Datetime ) As Integer
Days=DatePart(DateInterval.Day,D1)-DatePart(DateInterval.Day,D2)
Months=DatePart(DateInterval.Month,D1)-DatePart(DateInterval.Month,D2)
Years=DatePart(DateInterval.Year,D1)-DatePart(DateInterval.Year,D2)
If Days < 0 then
Months=Months-1
End If
If Months < 0 then
Years=Years-1
End If
If Months < 0 then
Months=Months+12
End If
Return Years
End Function
Public Shared Function CalMon(ByVal D3 As Datetime,ByVal D4 As Datetime ) As Integer
Days=DatePart(DateInterval.Day,D3)-DatePart(DateInterval.Day,D4)
Months=DatePart(DateInterval.Month,D3)-DatePart(DateInterval.Month,D4)
Years=DatePart(DateInterval.Year,D3)-DatePart(DateInterval.Year,D4)
If Days < 0 then
Months=Months-1
End If
If Months < 0 then
Years=Years-1
End If
If Months < 0 then
Months=Months+12
End If
Return Months
End Function
and using expression in SSRS fo display like this :
=IIF((Code.CalMon(Parameters!AgeCalcDate.Value,Fields!StudentBirthDate.Value))=1,Code.CalAge(Parameters!AgeCalcDate.Value,Fields!StudentBirthDate.Value) & " Years " & Code.CalMon(Parameters!AgeCalcDate.Value,Fields!StudentBirthDate.Value)
& " Month ",
Code.CalAge(Parameters!AgeCalcDate.Value,Fields!StudentBirthDate.Value) & " Years " & Code.CalMon(Parameters!AgeCalcDate.Value,Fields!StudentBirthDate.Value) & " Months ")
got the correct solution. -
Function MakeList(ByVal items As Object()) As String
If items Is Nothing Then
Return Nothing
END if
Dim builder As System.Text.StringBuilder =
New System.Text.StringBuilder()
builder.Append("<div>")
For Each item As Object In items
builder.Append("<div <ul>")
builder.Append(item)
builder.Append("</ul>")
Next
builder.Append("</div>")
Return builder.ToString()
End Function
Function Length(ByVal items as Object()) as Integer
If items is Nothing Then
Return 0
End If
Return items.Length
End FunctionHi Wintersbay,
According to your description, when you use the custom code in SSRS report, you got the error message.
To solve the problem, please refer to the custom code below:
Function MakeList(ByVal items As Object) As String
If items Is Nothing Then
Return Nothing
END if
Dim builder As System.Text.StringBuilder =
New System.Text.StringBuilder()
builder.Append("<div>")
For Each item As Object In items
builder.Append("<div <ul>")
builder.Append(item)
builder.Append("</ul>")
Next
builder.Append("</div>")
Return builder.ToString()
End Function
Function Length(ByVal items as Object) as Integer
If items is Nothing Then
Return 0
End If
Return items.Length
End Function
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
Wendy Fu
TechNet Community Support -
Using custom code in SSRS PDF rendering
Hi,
I have a written some custom code ( a simple function to maintain a counter ) in SSRS Report properties.
Everything works fine when I render the report in Report Viewer, but the custom code is not recognized when I render the report to PDF.
What is wrong with my code?
There is no error reported. The custom code is just getting skipped when I render to PDF.
My custom code is as follows..
Public Shared Dim iCounter AS Integer = 1
Public Function IncrementCounter(SomeValue As Boolean) As Boolean
iCounter = iCounter + 1
Return SomeValue
End Function
Public Function GetCounter() As Integer
Return iCounter
End Function
and my call to the custom code is..
=code.GetCounter()Hi ha_emp,
From your description, it seems that custom code work well when you preview the report. While it would be skipped when the report is exported to PDF. After testing the custom code in my environment,I find that the custom code will run again when exporting
the report, so when we run the report on Report Server and export it to PDF, the custom code will be run twice, the value will be counted twice.
Based on my research, I find that we can delete the “Shared” in the first row of the custom code to fix this issue. Then the custom code will works well on Report Server.
If there are any misunderstanding, please elaborate the issue for further investigation.
Thanks,
Katherine Xiong
We
are trying to better understand customer views on social support experience, so your participation in this
interview project would be greatly appreciated if you have time.
Thanks for helping make community forums a great place. -
Custom code dll as a data source for an SSRS report
I'm trying to create a report which relies on using some custom code written in VB.net. I am using the custom code to access the Server Management Objects SMO API in MSSQL 2012. I am able to supply an MSSQL object name (a database table
for example)and then return a list of dependant objects using the dependency walker class (stored procedures, triggers, UDF's, other tables etc.) which rely on the parent object if you will. I am able load the results into a dataset in the custom code. My
question is how can I get that dataset to be consumed as a data source and appear in my report. I've read many articles on how to use scripts to supply values for various report property settings. I just haven't seen an example of using a dll
to supply a dataset. I am assuming it is possible. Any thoughts or advice would be appreciated. CheersHi mdmck,
According to your description, you want to create an SSRS report with custom code as data source, right?
To use custom code in Reporting Services, we need to add a reference to your custom assembly, create a new CodeGroup for your custom assembly, and then grant full trust permissions. For detail information, please refer to the following steps:
Open the report that will reference the custom assembly.
On the Report menu, click Report Properties.
In the Report Properties dialog box, click the References tab.
Under References, click the ellipsis (...) button that is next to the Assembly name column header.
In the Add References dialog box, click Browse.
Locate and then click the custom assembly. Click Open.
In the Add References dialog box, click OK.
In the Report Properties dialog box, click OK.
If the custom assembly requires more permissions than the default Execution level permissions, we need to create a new CodeGroup for your custom assembly, and then grant full trust permissions.
Here are relevant threads you can reference:
https://social.technet.microsoft.com/Forums/en-US/c297bddc-c33c-4386-b284-41c1d87f37c6/custom-dlls-in-ssrs-reports?forum=sqlreportingservices
https://social.technet.microsoft.com/Forums/en-US/27de3f46-5174-480d-b4d1-5e32772dae35/ssrs-2005-custom-code-shared-data-source-connection-string?forum=sqlreportingservices
For more information about How to use custom assemblies or embedded code in Reporting Services, please refer to the following document:
https://support.microsoft.com/kb/920769?
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
If you have any feedback on our support, please click
here.
Wendy Fu
TechNet Community Support -
How to dynamically set width of SSRS columns in custom code?
How can I change the width of a table column based on a parameter value using custom code in SSRS?
If the parameter value is "Excel", I'd like the width to be 2 inches. If the parameter value is "Standard", I'd like the width to be 1 inch.Hi mmx_pdx,
Based on my research, we can only type static values for the width size in report. In Reporting Services, it not supported to set the size of width based on an expression currently. This is by design.
Personally, I recommend you that submit this suggestion at
https://connect.microsoft.com/SQLServer/. If the suggestion mentioned by customers for many times, the product team may consider to add the feature in the next SQL Server version. Your feedback is valuable for us to improve our products and increase the
level of service provided.
Thanks for your understanding.
Regards,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
hi sir
i am fresher,
i need breif about custom code in ssrs,
what is cutom code,
why it is used,
what is the perpose of this code...
help me to learn.
thank you.custom code is used mostly for implementing functionalities which cannot be done using standard features available in SSRS. Custom code should be written using .NET language. If you want to share same code across multiple reports you should make it into
a dll and reference it from all the required reports.
More details here
https://msdn.microsoft.com/en-us/library/ms156028.aspx
https://msdn.microsoft.com/en-us/library/ms159238.aspx
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
when iam previwing report this error is occured
System.Data.SqlClient.SqlException: Login failed for user 'FPS\hariprasad.a'.
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnechi pasted error .iam impleting custom code in ssrs like below
Public Shared Function DeleteData(Byval empno AS Integer) As String
Dim strResult As String
Dim conn As New System.Data.SqlClient.SqlConnection
conn.ConnectionString = "Integrated Security=SSPI;Data Source=172.16.1.111\DATA_SERVICES;Initial Catalog=Recounsiled"
Dim sql As String
sql = "sp_empno"
Dim com As New System.Data.SqlClient.SqlCommand
com.CommandText = sql
com.CommandType = System.Data.CommandType.StoredProcedure
com.Parameters.Add("@empno", System.Data.SqlDbType.Int).Value =empno
com.Connection = conn
Try
com.Connection.Open()
com.ExecuteNonQuery()
com.Connection.Close()
strResult = "Successful"
Catch ex As Exception
com.Connection.Close()
strResult = ex.ToString()
End Try
return strResult
End Function -
Custom code in SSRS gives error when uploaded to report in CRM online
Hi All;
Below is my custom code
Function SumLookup(ByVal items As Object()) As Decimal
If items Is Nothing Then
Return Nothing
End If
Dim suma As Decimal = New Decimal()
Dim ct as Integer = New Integer()
suma = 0
ct = 0
For Each item As Object In items
suma += Convert.ToDecimal(item)
ct += 1
Next
If (ct = 0) Then return 0 else return suma
End Function
and this code is used in
=Code.SumLookup(LookupSet(Fields!new_mainprogrammeid.Value & "," &
Fields!new_subprogrammeid.Value & "," &
Fields!new_outputs.Value & "," &
Fields!new_claimmonthid.Value,
Fields!new_mainprogrammeid.Value & "," &
Fields!new_subprogrammeid.Value & "," &
Fields!new_outputs.Value & "," &
Fields!new_claimmonthid.Value,
Fields!new_fte.Value, "JobOutcome"))
when this code is uploaded in CRM online report it gives an error
below is the error from the log file
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: An error occurred while trying to add the report to Microsoft Dynamics CRM. Try adding the report again. If this problem persists, contact your system administrator.Detail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
<ErrorCode>-2147188072</ErrorCode>
<ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Message>An error occurred while trying to add the report to Microsoft Dynamics CRM. Try adding the report again. If this problem persists, contact your system administrator.</Message>
<Timestamp>2014-10-07T14:21:25.5823821Z</Timestamp>
<InnerFault i:nil="true" />
<TraceText i:nil="true" />
</OrganizationServiceFault>
but when i remove the custom code and upload the lookup as below i dont get any error
=(LookupSet(Fields!new_mainprogrammeid.Value & "," &
Fields!new_subprogrammeid.Value & "," &
Fields!new_outputs.Value & "," &
Fields!new_claimmonthid.Value,
Fields!new_mainprogrammeid.Value & "," &
Fields!new_subprogrammeid.Value & "," &
Fields!new_outputs.Value & "," &
Fields!new_claimmonthid.Value,
Fields!new_fte.Value, "JobOutcome"))
I need to calculate the sum of fte hence needed the custom code
Any help on this much appreciated
Thanks
Pradnya07Hi Simran08,
According to your description, you fail to add your report to CRM due to the custom code. Right?
In this scenario, based on my knowledge, I find two issues in your custom code.
You pass the array Items as argument to the function. This array is from the LookupSet() function. However, it returns an concatenated string with commas. When you convert it into decimal, it will throw error.
In your For Each loop part, we should follow the format below:
For Each element In group
[statements]
[Exit For]
[statements]
Next [element]
It seems you miss Item after Next.
If you still have any question, please feel free to ask.
Best Regards,
Simon Hou -
SSRS Running Totals Custom Code
I have a report in which I need to total a column with an expression and created simple code to have a running total. When I run the report through report builder, the total only reflects the current page (it is 6 pages long) but if I export the report
out to Excel, the total is correct.
Below is the code:
Public running_roy as Double = 0
Public Function roy_tot(ByVal cust_type, ByVal roy, ByVal ret_value) as Double
Dim temp_var as Double
if cust_type = 0 then
running_roy = running_roy + roy
if ret_value = 0 then
temp_var = roy
else
temp_var = running_roy
end if
ELSE
temp_var = 0
end if
return temp_var
End Function
If I change the Public variable to "Public Shared" the totals change as I flip back and forth between the pages in report builder.
Any suggestions?Hello alan2624,
Thanks for your clarification.
In the report, the custom code will be compiled as a class before it is used. Every time the page is loaded, the class on the page will be initialized. The un-shared (non-static) instance will be reset. Therefore, you will see the value is reset back to
zero if the public variable is not announced as "Shared". If you announced it as shared, then the variable is on the class level. It will not be changed by instance initializing. In addition, any operations on the variable will be recorded. This is not the
bug, but it is by design of the VB.net code.
If you export the report to the Excel, I think it will only generate a single page, and the total value is only the last one. It should be correct. If it is used in the pages in browser, I suggest you need design your code carefully for VB.net design.
If you have any questions about this issue, please let me know.
Regards,
Edward
Edward Zhu
TechNet Community Support -
How to Test SSRS Custom Data Extension in TSql
Hi There,
I have created a custom data extenstion for SSRS 2008 Reporting Service.
I can test the CDE in the Report DataSet -> DataSet Properties -> Query Designer -> Run Query.
In the Command Text I pass parameters to the invoked VB code which is of type "BaanstedeCds" then name of my custom data extension.
I can even Attach the Visual Studio VB Code Project that is invoked by the Query Designer an debug the code.
The custom data extension works perfectly in SSRS.
However I have not found a way yet to run BaanstedeCds (with a parametertext) from within SSMS 2008 by using an T-SQL statement!!! Is there a way to use the SSRS Custom Data Extension in Sql Server Management Studio using the dataset type I used in
SSRS 2008?
Because I am leaving the path of using Custom Assemblies in SSMS, for deploying an testing that way is undoable for me.
I is to complicated and in order to properly debug these routines the entire solution of multiple projects is deployed each time even the slightest change has been made to the VB code. Also if I want to deploy from Test to Production it is very hard. I have
to detach the databases etc, ect. Note my previous question about this subject that remained unanswered!!!
Using the Custom Data Extension the problems are a lot less. However I how do I use a routine in the CDS in T-SQL, like I could invoke a routine in the Custom Code Assemblies?
I "hate" CLR routines. I have extreme trouble managing these CLR's as I explained in my post and other posts in the past.
You just cannot build a maagable system that way.
I had to convert all the CLR's (I had a lot of them) to Custom Data Extension Functions, as they do not have all the drawbacks of CLR's.
And using the CDE with all the converted CLR's in it works much better for me in the Report Manager.
However in order to test de CDE I must invoke the CDE in a Windows Form something like this:
Private Sub cmdGetData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGetData.Click
Dim CommandText As String = ""
' Get Parameters for CDE GetData
CommandText = txtAdoCds.Text
Dim Rdr As New BstCds.BaanstedeCdsReader(CommandText)
' Invoke GetData Function of CDE Rdr
' Input: CommandText: txtAdoCds.Text = TextBox on TestForm
' Output: DataTable: RdrDataTable
Call Rdr.GetData(CommandText)
If Not Rdr.RdrRetVal Then
GoTo End_Method
End If
' Show DataTable: RdrDataTable (in Excel)
If Not BstOff.ToonTabel(DataTabel:=Rdr.RdrDataTable) Then
Exit Sub
End If
End_Method:
End Sub
'=========================================================================
' File: BaanstedeCdsReader.vb
' Summary: Provides a means of reading one or more forward-only streams
' of result sets obtained by executing a command at a data source,
' and is implemented by Baanstede Data Processing Extensions
' that access BaanstedeIw3-routines.
'=========================================================================
Public Class BaanstedeCdsReader
Implements IDataReader
#Region "Public Variables"
Public RdrRetVal As Boolean = False
Public RdrSqlSel As String = ""
Public RdrDataTable As DataTable = New DataTable
#End Region
#Region "Constructors"
#End Region
#Region "IDataReader Members"
#End Region
' GetData '
#Region "GetData Method"
'==================================================================================================
'We are executing the command using the connection string that connects to the Active Directory.
'Hard coding of the connection string is because it is the same for all the ADs.
'Once we read the data using a DataReader, we place the same in a DataTable so that can be used for
'Other processings.
' Public Sub GetData(ByVal _CommandText As String)
' Output in Public RdrDataTable As DataTable
'==================================================================================================
Public Sub GetData(ByVal _CommandText As String)
' Ophalen Data in DataTabel '
RdrRetVal = False
' Fills RdrDataTable Using _COmmandText
RdrRetVal = True
End Sub
But can I invoke Report Manager Source Type BaanstdeCds's .BaanstedeCdsReader.GetData(CommandText) in TSQL any other way then using CLR ?
Regards Jos
It works, but it does not work (The program runs, but does not produce the desired result)Hi Josje,
Thank you for your question.
I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated.
Thank you for your understanding and support.
Thanks,
Wendy Fu
Wendy Fu
TechNet Community Support -
Hi,
I Haven't used Vb.net, as I work on C#, But in SSRS it supports only VB.net code as custom coding, so i coded in c# and converted to VB.net from online converter. The code i got from online converter is working fine in local i.e when i preview in BI studio,
but when i try to deploy the same i'm getting error
Error 3
There is an error on line 12 of custom code: [BC30201] Expression expected.
0 0
Below is the code:
' -- Author : Jai Anand
' -- Date : 06-05-2014
' -- Discription : To split the given string of numbers and Assign the days for it,
' -- example: if integer 1 - (Su) --> Sunday, 2 - (Mo) --> Monday
public Function FindPlanDays(plandate As String) As String
Dim planarray As String() = New String() {}
Dim days As String = ""
planarray = plandate.Split(","C)
Dim i As Integer = 0
While i < planarray.Length
Dim day As String = If(planarray(i) = "1", "Su,", If(planarray(i) = "2", "Mo,",
If(planarray(i) = "3", "Tu,", If(planarray(i) = "4", "We,", If(planarray(i) = "5", "Th,", If(planarray(i)="6","Fr,", If(planarray(i) = "7", "Sa,", String.Empty)))))))
days = days & day
i += 1
End While
days = If(days <> String.Empty, " (" + days.TrimEnd(","C) + ")", days)
Return days
End Function
Kindly check the code, if any issue is there,give me the solution..Thank youHi,
I found the solution and the report is deployed . The issue was with If and we should suffix with space and underscore( _) at the end of the line break and continues in next line (i.e if the statement continues in next line).
iif has always been available in VB, even in VB6.
Dim day As String = Iif(planarray(i) = "1", "Su,","Mon")
It is not a true operator, as such, but a function in the Microsoft.VisualBasic namespace.
so the modified code which worked fine to deploy
' -- Author : Jai Anand
' -- Date : 06-05-2014
' -- Discription : To split the given string of numbers and Assign the days for it,
' -- example: if integer 1 - (Su) --> Sunday, 2 - (Mo) --> Monday
public Function FindPlanDays(plandate As String) As String
Dim planarray As String() = New String() {}
Dim days As String = ""
planarray = plandate.Split(","C)
Dim i As Integer = 0
While i < planarray.Length
Dim day As String = Iif(planarray(i) = "1", "Su," ,Iif(planarray(i) = "2", "Mo,", _
Iif(planarray(i) = "3", "Tu,", Iif(planarray(i) = "4", "We,", Iif(planarray(i) = "5", "Th,", _
Iif(planarray(i) ="6","Fr,", Iif(planarray(i) = "7", "Sa,", String.Empty)))))))
days = days & day
i += 1
End While
days = Iif(days <> String.Empty, " (" + days.TrimEnd(","C) + ")", days)
Return days
End Function
Maybe you are looking for
-
Hi friends, Now my problem in the sense, is creating during the loading of the module..... In under Execution Plans tab-----> i clicked NEW and given name as HRMS After that i enabled the check box FULL LOAD ALWAYS and under the SUBJECT AREAS tab i c
-
Duplicate photos now in Photo from iPhoto
Hi, I uploaded photos from my Mac to my iPad(3) using Photosync. The album appears nicely under Albums in the Photo app along with the pics in Camera Roll. I then make my edits in iPhoto (latest relase). So then, in iPhoto, i have the pics with the l
-
Sonic Wall NetExtender stuck on "processing"
Sonic Wall NetExtender 7.0.203 is not getting past "processing" when connecting. Works fine in Windows 8.1. Have tried re-installing to no avail.
-
Best method for secure Internet ?????
OK, So I wasn't sure where to put this post, so I figured I would start with the system I am using and go from there. The Problem: I am trying to set up a secure method in which I can use Internet services as I make my way from non-secure places thro
-
I have tried the solutions already posted for not able to print from Ipad and the Ipad still wont find the Air Printer. I have a new HP 8610 and I can print using the HP e print from the Ipad and the desk top PC work perfect. The printer SSID is the