Cutting straight to the chase... I've got an ASPX page attempting to use a public shared function I've written called "IsMemberOfRole". This I know works. However, some simple code I've put inside of this function causes the following error:
An error was encountered on page /loggedin/OrganisationPost.aspx.
The error was: System.Web.HttpUnhandledException: Exception of type System.Web.HttpUnhandledException was thrown. ---> System.NullReferenceException: Object reference not set to an instance of an object.
Here's the code snippet causing the problem:
SQLGetAllUserRoles.CommandType = System.Data.CommandType.StoredProcedure
SQLGetAllUserRoles.CommandText = ("dbo.[GetAllUserRoles]")
SQLGetAllUserRoles.Connection = SQLConnection1
SQLGetAllUserRoles.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Username", System.Data.SqlDbType.VarChar, 1))
SQLGetAllUserRoles.Parameters("@Username").Value = Username
Dim strRoles As String
strRoles = SQLGetAllUserRoles.ExecuteScalar
Dim arrAllRoles As Array
arrAllRoles = strRoles.Split(",") ******************** 'WHAT'S WRONG WITH THIS? It works in other pages.
Dim Role As String
For Each Role In arrAllRoles
If UCase(Role) = UCase(RoleName) Then
So this is my problem! I think I'm doing this right... I can DEFINATELY say that the SQL Stored Procedure dbo.[GetAllUserRoles] works correctly, and definately returns a comma separate list of values for the user I am testing it with.
Anyone shed any light?
Points to the first person who correctly provides a step-by-step fix!