Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

What is wrong with my code?

Avatar of HSI_guelph
HSI_guelphFlag for Canada asked on
Microsoft SQL Server 2008SSRS
6 Comments1 Solution207 ViewsLast Modified:
I'm trying to take the UserID of the logged on user and test if they have permission to view the report for the selected employee.  If they have chosen their own name then the table is visible, if not then the table is hidden.  I got the code to work with only one parameter passed; checking who's logged in and saying they can view a table or not but that was all or nothing.  Now they should be able to see the page if they have selected themselves from the list but not anyone else.  Unless they are executives who can see everything :)

Works great!
Public Function CheckPermissions(ByVal s As String) As String
	Dim strBuilder As New System.Text.StringBuilder(s)
	Dim Visible as String = "False"
	Dim Hidden as String = "True"
	If s.Contains("*****\ar") Then
		Return Visible
	Else If s.Contains("*****\dt") Then
		Return Visible
	Else If s.Contains("*****\jb") Then
		Return Visible
	Else If s.Contains("*****\lv") Then
		Return Visible
	Else If s.Contains("*****\rb") Then
		Return Visible
	Else If s.Contains("*****\rw") Then
		Return Visible
	Else Return Hidden
	End If 
End Function

=iif(Code.CheckPermissions(User.UserId) = "False" , False, True)


Not working :(
Public Function CheckPermissions(ByVal s As String, ByVal t As String) As String
	Dim strBuilder As New System.Text.StringBuilder(s)
	Dim strBuilder2 As String = t
	Dim Visible as String = "False"
	Dim Hidden as String = "True"
	If s.Contains(strBuilder2) Then
		Return Visible
	Else Return Hidden
	End If 
End Function

Public Function CheckPermissions(ByVal s As String, ByVal t As String) As String
	Dim strBuilder As New System.Text.StringBuilder(s)
	Dim strBuilder2 As New System.Text.StringBuilder(t)
	Dim Visible as String = "False"
	Dim Hidden as String = "True"
	If s.Contains(selectedEmployee) Then
		Return Visible
	Else Return Hidden
	End If 
End Function
ASKER CERTIFIED SOLUTION
Avatar of James0628
James0628

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answers