G
Guest
I've gotten quite comfortable using a DataReader to grab a single value from
a table
as in the following:
Public Shared Function IsUserAdmin(ByVal strNUID As String) As Long
Dim dr As SqlDataReader
Dim conMembers As SqlConnection =
MembershipDB.GetMembershipConnection()
Dim cmd As New SqlCommand("SELECT [Level] FROM dbo.user_settings
WHERE [Address] = @NUID", conMembers)
cmd.CommandType = CommandType.Text
cmd.Parameters.Add("@NUID", SqlDbType.NVarChar, 50).Value = strNUID
conMembers.Open()
dr = cmd.ExecuteReader(CommandBehavior.SingleRow)
'check if the clinical value is 1
If dr.Read Then
'if it is then the user admin privileges
'find out the level
Return dr("Level")
Else 'if no user is found - it means the user doesn't have any admin
rights
Return 0
End If
conMembers.Close()
conMembers.Dispose()
conMembers = Nothing
End Function
I would like to practice using DataTables but I need a little help getting
started- could someone tranlate this same functionality (above) for a
DataTable?
a table
as in the following:
Public Shared Function IsUserAdmin(ByVal strNUID As String) As Long
Dim dr As SqlDataReader
Dim conMembers As SqlConnection =
MembershipDB.GetMembershipConnection()
Dim cmd As New SqlCommand("SELECT [Level] FROM dbo.user_settings
WHERE [Address] = @NUID", conMembers)
cmd.CommandType = CommandType.Text
cmd.Parameters.Add("@NUID", SqlDbType.NVarChar, 50).Value = strNUID
conMembers.Open()
dr = cmd.ExecuteReader(CommandBehavior.SingleRow)
'check if the clinical value is 1
If dr.Read Then
'if it is then the user admin privileges
'find out the level
Return dr("Level")
Else 'if no user is found - it means the user doesn't have any admin
rights
Return 0
End If
conMembers.Close()
conMembers.Dispose()
conMembers = Nothing
End Function
I would like to practice using DataTables but I need a little help getting
started- could someone tranlate this same functionality (above) for a
DataTable?