Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Writing custom code for reporting services Expand / Collapse
Author
Message
Posted Thursday, June 24, 2010 6:06 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, July 16, 2012 2:33 AM
Points: 2, Visits: 35
I am interested in writing code for my new reporting services projects which I have just gotten involved with at work. Can anyone tell what language and syntax is required? Also are there any function reference libraries available for me to look at to see what I can use?

Thanks

Billy Knight
Post #942384
Posted Thursday, June 24, 2010 8:48 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: Moderators
Last Login: Today @ 12:54 PM
Points: 1,822, Visits: 3,484
Billy,

If you can expand a little on *why* you want to write code for this project, it might help us point you towards where to look as there are several areas in which you could write code.





Steve.
Post #942503
Posted Thursday, June 24, 2010 8:57 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, July 16, 2012 2:33 AM
Points: 2, Visits: 35
Hi Steve,

Thanks for responding. I have been creating reports in reporting services for a while now, and we have just upgraded to SSRS 2008. I am trying to beef up on a few areas in reporting servces where I have not needed to go before. I am now in charge of developing new reports for our clients to be used alongside the existing software we develop and provide for them. I am just interested in the particular language and syntax to use for writing code in reporting services. I take it you can put as many functions in there as you like? Can I use VBA??? Is it Microsoft Visual Basic 2008 like I use in SSIS script tasks?
Post #942512
Posted Thursday, June 24, 2010 11:52 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: Moderators
Last Login: Today @ 12:54 PM
Points: 1,822, Visits: 3,484
Ok, sounds like you're interested just in adding custom code to your reports. I believe it's VB 2008, not VBA. MSDN has a section using code here.


Steve.
Post #942622
Posted Tuesday, June 29, 2010 9:46 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, September 25, 2014 8:48 AM
Points: 1,293, Visits: 1,560
Sample to get you started:


Private bOddRow As Boolean
'*************************************************************************
' -- Display green-bar type color banding in detail rows
' -- Call from BackGroundColor property of all detail row textboxes
' -- Set Toggle True for first item, False for others.
'*************************************************************************
Function AlternateColor(ByVal OddColor As String, _
ByVal EvenColor As String, ByVal Toggle As Boolean) As String
If Toggle Then bOddRow = Not bOddRow
If bOddRow Then
Return OddColor
Else
Return EvenColor
End If
End Function


Then to use this on a table, add this to the expression on BackgroundColor:
=Code.AlternateColor("White", "Whitesmoke", TRUE)



_____________________________________________________________________________________
gsc_dba
Post #944772
Posted Tuesday, July 13, 2010 1:06 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, July 16, 2010 2:00 AM
Points: 44, Visits: 65
Hi,

Custom code u can use VB Functions... c# is not allowed.. but u can create DLL (Dynamic Link library) using C# or VB.net language..

in REPORT -> PROPERTIES -> CODE (u can write your code here)...

in REFERENCE TAB - > add dlls / references...


Regards,
Gayathri
Post #951175
Posted Friday, November 18, 2011 5:14 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, November 18, 2011 5:04 AM
Points: 26, Visits: 39
Hi All
I wrote and Cutome code as below , that works well in development environment,
During Preview it gives me perfect Output,
but after the deployement it gives me error.
What must be fix to this. Please attached files where i added customcode and reference to System.data.dll



Function IsBudgetRevised(ByVal Proj_Id As Integer, ByVal Comp_Id As Integer, ByVal Sbu_Id As Integer, ByVal Contract_Type As Integer, ByVal FinYear as Integer) As String
Dim oConn As New System.Data.SqlClient.SqlConnection
oConn.ConnectionString = "Data Source=C-41396\C41396;" & _
"Initial Catalog=Finance_Dashboard; Integrated Security=true"
oConn.Open()
Dim oCmd As New System.Data.SqlClient.SqlCommand
oCmd.Connection = oConn
oCmd.CommandText = "Select Convert(Varchar(50),UpdatedBudget)+'-'+Convert(Varchar(50),LatestForecast) from tbl_CalculateUpdatedBudLatestFor" & _
" Where Proj_Id=@Proj_Id" & _
" and Comp_Id=@Comp_Id" & _
" and Sbu_Id=@Sbu_Id " & _
" and Contract_Type=@Contract_Type " & _
" and FinYear= @FinYear "
oCmd.Parameters.AddWithValue("@Proj_Id", Proj_Id)
oCmd.Parameters.AddWithValue("@Comp_Id", Comp_Id)
oCmd.Parameters.AddWithValue("@Sbu_Id", Sbu_Id)
oCmd.Parameters.AddWithValue("@Contract_Type", Contract_Type)
oCmd.Parameters.AddWithValue("@FinYear",FinYear)
Dim nRetVal As String = oCmd.ExecuteScalar()
oConn.Close()
If(nRetVal<>Nothing)
Return nRetVal
else
Return "0-0"
End If
End Function




  Post Attachments 
SSRS-Error.bmp (41 views, 2.93 MB)
Post #1208245
Posted Friday, July 13, 2012 9:00 AM


Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Saturday, June 29, 2013 6:47 AM
Points: 12, Visits: 178
Hi

There's a tutorial on embedding code here (with a couple of full examples). I'm hoping to get round to writing one on custom assemblies next, to complete the picture!


Andy is a director of Wise Owl, a UK company providing training courses (and occasional consultancy) in SQL, Reporting Services, Integration Services and Analysis Services, as well as in many other Microsoft software applications. You can see more about Wise Owl's SQL Server training courses here.
Post #1329529
Posted Thursday, June 27, 2013 2:22 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, June 18, 2014 12:10 PM
Points: 10, Visits: 84
gsc_dba (6/29/2010)

Private bOddRow As Boolean
'*************************************************************************
' -- Display green-bar type color banding in detail rows
' -- Call from BackGroundColor property of all detail row textboxes
' -- Set Toggle True for first item, False for others.
'*************************************************************************
Function AlternateColor(ByVal OddColor As String, _
ByVal EvenColor As String, ByVal Toggle As Boolean) As String
If Toggle Then bOddRow = Not bOddRow
If bOddRow Then
Return OddColor
Else
Return EvenColor
End If
End Function


Then to use this on a table, add this to the expression on BackgroundColor:
=Code.AlternateColor("White", "Whitesmoke", TRUE)



Regarding this example, I was able to get the following to work for me:

BackgroundColor code for the rows:
=iif(RowNumber(Nothing) Mod 2,"White","Yellow")

If you want to use Report Code, though, I did this:
Function fToggleColor(ByVal bToggle As Boolean) As String
If bToggle Then
Return "White"
Else
Return "Yellow"
End If
End Function

with this in BackgroundColor:
=Code.fToggleColor(iif(RowNumber(Nothing) Mod 2,True,False))

I would be careful with RowNumber because I'm not fully aware of its behavior. I believe RowNumber would take the group name if there were groups involved. Not sure.
Post #1468345
Posted Thursday, June 27, 2013 2:57 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, June 18, 2014 12:10 PM
Points: 10, Visits: 84
billy.knight (6/24/2010)
I am interested in writing code for my new reporting services projects which I have just gotten involved with at work. Can anyone tell what language and syntax is required? Also are there any function reference libraries available for me to look at to see what I can use?

Thanks

Billy Knight


Visual Basic is the language, and here are some links that might be related to the reference libraries:

Custom Code and Assembly References
http://technet.microsoft.com/en-us/library/ms159238%28v=sql.105%29.aspx

Visual Basic Run-Time Library Members:
http://msdn.microsoft.com/en-US/library/c157t28f%28v=vs.90%29.aspx

I copied the 2008 or 2008 R2 links, so be sure to change it to whatever version of SQL Server you're using at the top of each page.
Post #1468355
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse