473,385 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

DataReader Problem

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.Id entity, roleListArray)
End If
Jun 13 '06 #1
3 1167
Your access code looks fine.

What is the value of User.Identity.Name - is it what you expect? Is it empty
string? It is possible that this is not the right value, and so nothing is
being retrieved.

Have you traced through this one line at a time? Do any rows come back at
all?

As an aside, you never close the connection in this code snippet. This
whole thing needs to be in a try/finally block that cleans everything up or
in a Using block.

"Tim::.." <myatix_at_hotmail.com> wrote in message
news:8D**********************************@microsof t.com...
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.Id entity, roleListArray)
End If

Jun 13 '06 #2
The user.Identity.Name looks fine when I run the debug... ooopppsss no it
doesn't!

Thanks!

Pulling the wrong thing from the db!

"Marina Levit [MVP]" wrote:
Your access code looks fine.

What is the value of User.Identity.Name - is it what you expect? Is it empty
string? It is possible that this is not the right value, and so nothing is
being retrieved.

Have you traced through this one line at a time? Do any rows come back at
all?

As an aside, you never close the connection in this code snippet. This
whole thing needs to be in a try/finally block that cleans everything up or
in a Using block.

"Tim::.." <myatix_at_hotmail.com> wrote in message
news:8D**********************************@microsof t.com...
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.Id entity, roleListArray)
End If


Jun 13 '06 #3
Just one more quick question???

How do I redirect to another page if the Request.IsAuthenticated is False
and it is the second time it is false???

IE: When you load the page you get the normal page! But if you try again you
get another page!

I tried Response.Redirect but that means you get redirected as soon as the
default.aspx loads...

Thanks again!

"Marina Levit [MVP]" wrote:
Your access code looks fine.

What is the value of User.Identity.Name - is it what you expect? Is it empty
string? It is possible that this is not the right value, and so nothing is
being retrieved.

Have you traced through this one line at a time? Do any rows come back at
all?

As an aside, you never close the connection in this code snippet. This
whole thing needs to be in a try/finally block that cleans everything up or
in a Using block.

"Tim::.." <myatix_at_hotmail.com> wrote in message
news:8D**********************************@microsof t.com...
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.Id entity, roleListArray)
End If


Jun 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Yasutaka Ito | last post by:
Hi, My friend had a little confusion about the working of DataReader after reading an article from MSDN. Following is a message from him... <!-- Message starts --> I was going thru DataReader...
20
by: Mark | last post by:
Hi all, quick question , a DataView is memory resident "view" of data in a data table therefore once populated you can close the connection to the database. Garbage collection can then be used to...
6
by: Yasutaka Ito | last post by:
Hi, My friend had a little confusion about the working of DataReader after reading an article from MSDN. Following is a message from him... <!-- Message starts --> I was going thru DataReader...
3
by: Carlos Lozano | last post by:
Hello, I am having a problem getting the selectedValue from a dropdownlist that is populated with a dataReader and just can't see the problem. I did the following: dim dr as DataReader dr...
3
by: Johnny Jörgensen | last post by:
I've got an error that I simply cannot locate: I've got a form in which I use a datareader object to read information from a db. After the read, I close the reader and I dispose of both the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.