G
Guest
Can someone tell my why my DataReader doesn't read and create the array???
I think it is something to do with the reader = cmd.ExecuteReader line but
I'm not sure what it be!
Thanks
If Request.IsAuthenticated Then
Dim objConn
Dim cmd As OleDbCommand
Dim strSQL As String
strSQL = "SELECT GroupAccess FROM person where personNo =
@Username"
objConn = New
OleDbConnection(ConfigurationSettings.AppSettings("strConn"))
cmd = New OleDbCommand(strSQL, objConn)
'Determine this user's roles
Dim reader As OleDbDataReader
cmd.Parameters.Add("@Username", User.Identity.Name)
objConn.Open()
reader = cmd.ExecuteReader
' Create an array of role names
Dim roleList As New ArrayList
Do While reader.Read
roleList.Add(reader("GroupAccess"))
Loop
reader.Close()
'Convert the roleList ArrayList to a String array
Dim roleListArray As String() = roleList.ToArray(GetType(String))
'Add the roles to the User Principal
HttpContext.Current.User = New
System.Security.Principal.GenericPrincipal(User.Identity, roleListArray)
End If
I think it is something to do with the reader = cmd.ExecuteReader line but
I'm not sure what it be!
Thanks
If Request.IsAuthenticated Then
Dim objConn
Dim cmd As OleDbCommand
Dim strSQL As String
strSQL = "SELECT GroupAccess FROM person where personNo =
@Username"
objConn = New
OleDbConnection(ConfigurationSettings.AppSettings("strConn"))
cmd = New OleDbCommand(strSQL, objConn)
'Determine this user's roles
Dim reader As OleDbDataReader
cmd.Parameters.Add("@Username", User.Identity.Name)
objConn.Open()
reader = cmd.ExecuteReader
' Create an array of role names
Dim roleList As New ArrayList
Do While reader.Read
roleList.Add(reader("GroupAccess"))
Loop
reader.Close()
'Convert the roleList ArrayList to a String array
Dim roleListArray As String() = roleList.ToArray(GetType(String))
'Add the roles to the User Principal
HttpContext.Current.User = New
System.Security.Principal.GenericPrincipal(User.Identity, roleListArray)
End If