VB.NET

Moderators: seancampbell
Number of threads: 4022
Number of posts: 10035

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
dataSource for login template Posted by simmonsl on 19 Dec 2006 at 4:33 PM
Problem creating a DataSource for a ListBox in the template of a login control. It is not the same as creating a DataSource outside of this login control template. Any help would be appreciated.
Code Snippet below: Login control includes a list to choose from.

Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim aAgencyList As New ArrayList

If Request.QueryString("LO") = "True" Then
Session.Clear()
End If

aAgencyList.Add("Data1")
aAgencyList.Add("Data2")
aAgencyList.Add("Data3")
aAgencyList.Add("Data4")


Here is the problem______________________________________________

'Login1.Controls.Item(0).TemplateSourceDirectory(aAgencyList)
'Login1.Controls.Item(0) = aAgencyList
______________________________________________________________________

Login1.Controls.Item(0).DataBind()

End Sub


Report
Re: dataSource for login template Posted by DrMarten on 20 Dec 2006 at 5:22 AM
This message was edited by DrMarten at 2006-12-20 5:24:35

: Problem creating a DataSource for a ListBox in the template of a login control. It is not the same as creating a DataSource outside of this login control template. Any help would be appreciated.
: Code Snippet below: Login control includes a list to choose from.
:
: Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
: Dim aAgencyList As New ArrayList
:
: If Request.QueryString("LO") = "True" Then
: Session.Clear()
: End If
:
: aAgencyList.Add("Data1")
: aAgencyList.Add("Data2")
: aAgencyList.Add("Data3")
: aAgencyList.Add("Data4")
:
:
: Here is the problem______________________________________________
:
: 'Login1.Controls.Item(0).TemplateSourceDirectory(aAgencyList)
: 'Login1.Controls.Item(0) = aAgencyList
: ______________________________________________________________________
:
: Login1.Controls.Item(0).DataBind()
:
: End Sub

____________________________________________________________________

Hi,

Are you wanting more than one property for your LOGIN template like;
userName, passWord, emailAddress?

If so why not use a STRUCTURE or create a login CLASS?

If i can understand what you are after in more detail i may be able to help further. Are you after creating a drop-down input box for a limited number of users to login with default user-names in an ARRAYLIST?

If so you would need to write the arraylist to a file and load the info from the file at run-time, i.e. within the FORM_LOAD event.

Using an arraylist you can Add or Remove users so i understand what you might be wanting.


Regards,

Dr M.
Report
Re: dataSource for login template Posted by simmonsl on 20 Dec 2006 at 8:04 AM
: This message was edited by DrMarten at 2006-12-20 5:24:35

: : Problem creating a DataSource for a ListBox in the template of a login control. It is not the same as creating a DataSource outside of this login control template. Any help would be appreciated.
: : Code Snippet below: Login control includes a list to choose from.
: :
: : Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
: : Dim aAgencyList As New ArrayList
: :
: : If Request.QueryString("LO") = "True" Then
: : Session.Clear()
: : End If
: :
: : aAgencyList.Add("Data1")
: : aAgencyList.Add("Data2")
: : aAgencyList.Add("Data3")
: : aAgencyList.Add("Data4")
: :
: :
: : Here is the problem______________________________________________
: :
: : 'Login1.Controls.Item(0).TemplateSourceDirectory(aAgencyList)
: : 'Login1.Controls.Item(0) = aAgencyList
: : ______________________________________________________________________
: :
: : Login1.Controls.Item(0).DataBind()
: :
: : End Sub
:
: ____________________________________________________________________
:
: Hi,
:
: Are you wanting more than one property for your LOGIN template like;
: userName, passWord, emailAddress?
:
: If so why not use a STRUCTURE or create a login CLASS?
:
: If i can understand what you are after in more detail i may be able to help further. Are you after creating a drop-down input box for a limited number of users to login with default user-names in an ARRAYLIST?
:
: If so you would need to write the arraylist to a file and load the info from the file at run-time, i.e. within the FORM_LOAD event.
:
: Using an arraylist you can Add or Remove users so i understand what you might be wanting.
:
:
: Regards,
:
: Dr M.
:
I have come up with a not so elegant solution.
I deleted the login title row and above the login template I Put the title in a panel & label. Below it the listBox. I can create the DataSource for the listBox outside of the login template. I would like to know how to accomplish this inside the template.
The Arraylist is populate from a file. I coded a simple array incase someone wanted to try the code. The listBox is for the user to select the agency he belongs to to prevent multiple login names. I just cant get the dataSource created within the template.
Karen
Report
Re: dataSource. See the toolbox DataSource controls. [Amended]. Posted by DrMarten on 20 Dec 2006 at 8:47 AM
This message was edited by DrMarten at 2006-12-20 9:23:59

: : : Problem creating a DataSource for a ListBox in the template of a login control. It is not the same as creating a DataSource outside of this login control template. Any help would be appreciated.
: : : Code Snippet below: Login control includes a list to choose from.
: : :
: : : Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
: : : Dim aAgencyList As New ArrayList
: : :
: : : If Request.QueryString("LO") = "True" Then
: : : Session.Clear()
: : : End If
: : :
: : : aAgencyList.Add("Data1")
: : : aAgencyList.Add("Data2")
: : : aAgencyList.Add("Data3")
: : : aAgencyList.Add("Data4")
: : :
: : :
: : : Here is the problem______________________________________________
: : :
: : : 'Login1.Controls.Item(0).TemplateSourceDirectory(aAgencyList)
: : : 'Login1.Controls.Item(0) = aAgencyList
: : : ______________________________________________________________________
: : :
: : : Login1.Controls.Item(0).DataBind()
: : :
: : : End Sub
: :
: : ____________________________________________________________________
: :
: : Hi,
: :
: : Are you wanting more than one property for your LOGIN template like;
: : userName, passWord, emailAddress?
: :
: : If so why not use a STRUCTURE or create a login CLASS?
: :
: : If i can understand what you are after in more detail i may be able to help further. Are you after creating a drop-down input box for a limited number of users to login with default user-names in an ARRAYLIST?
: :
: : If so you would need to write the arraylist to a file and load the info from the file at run-time, i.e. within the FORM_LOAD event.
: :
: : Using an arraylist you can Add or Remove users so i understand what you might be wanting.
: :
: :
: : Regards,
: :
: : Dr M.
: :
: I have come up with a not so elegant solution.
: I deleted the login title row and above the login template I Put the title in a panel & label. Below it the listBox. I can create the DataSource for the listBox outside of the login template. I would like to know how to accomplish this inside the template.
: The Arraylist is populate from a file. I coded a simple array incase someone wanted to try the code. The listBox is for the user to select the agency he belongs to to prevent multiple login names. I just cant get the dataSource created within the template.
: Karen


______________________________________________________________________

Hi,

Please PASTE your entire code into an email with no other text to me at my university email account at e5117204@tees.ac.uk

finish the email with "2003" or "2005" for the version of Visual Studio you are using and i'll see what i can do.[/red]

Attach a file with some make-believe user names etc if the code is loading in file data, with the SAME filename your code is using.

If you feel any comments may be useful then add them in to your code, thanks.

Alternatively drop one of the datasource controls on your FORM/PAGE from the toolbox data area.
Select from;

SqlDataSource
AccessDataSource
ObjectDataSource
XMLDataSource or
SiteMapDataSource




Regards,

Dr M.

Report
You might want to do it this way in Page_Load Sub instead.>> Posted by DrMarten on 21 Dec 2006 at 8:28 AM
This message was edited by DrMarten at 2006-12-21 8:31:31

Hi,

Please see my other post from today 1st for the relevance of arraylist
objReturnData

 Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load

        Dim aAgencyList As New ArrayList
        aAgencyList = objData.objReturnData

        If Request.QueryString("LO") = "True" Then
            Session.Clear()
        End If


        objData = New DataManager(ConfigurationManager.AppSettings("DatabaseServer"), _
          ConfigurationManager.AppSettings("DatabaseCatalog"), ConfigurationManager.AppSettings("DatabaseUsername"), _
          ConfigurationManager.AppSettings("DatabasePassword"))

        Dim index As Integer
        Dim myControl As ListBox
        myControl = Me.FindControl("lstAgency")
        myControl.SelectionMode = ListSelectionMode.Single
        For index = 0 To objData.objReturnData.Count
            myControl.SelectedIndex = index
            myControl.SelectedValue = aAgencyList(index)
            ' myControl.SelectedValue = objData.objReturnData(index)
            ' aAgencyList(index, index) = objData.FetchActiveAgencies
            'lstAgency.Item(index) = aAgencyList(index, index)
        Next


        'Login1.Controls.Item(0).datasource = aAgencyList
        'Login1.Controls.Item(0).TemplateSourceDirectory(aAgencyList)
        'Login1.Controls.Item(0) = aAgencyList

        Login1.Controls.Item(0).DataBind()


    End Sub




Regards,

Dr M.

Report
Hi, i have done the following but still have an "undefined variable".. Posted by DrMarten on 21 Dec 2006 at 7:32 AM
This message was edited by DrMarten at 2006-12-21 8:10:25

Hi,

2nd line in DataManager.Vb in function CheckUserPassword
has AgencyUser as an undefined type. The line is>>
Dim objReturn As AgencyUser

 Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load
        'Dim aAgencyList As New ArrayList

        If Request.QueryString("LO") = "True" Then
            Session.Clear()
        End If


        objData = New DataManager(ConfigurationManager.AppSettings("DatabaseServer"), _
          ConfigurationManager.AppSettings("DatabaseCatalog"), ConfigurationManager.AppSettings("DatabaseUsername"), _
          ConfigurationManager.AppSettings("DatabasePassword"))

' I've added the following to populate your listbox
' from your FetchActiveAgencies function.
        Dim index As Integer
        Dim myControl As ListBox
        myControl = Me.FindControl("lstAgency")
        myControl.SelectionMode = ListSelectionMode.Single
'This loop may need to start with a 1.
' I can't remember whether 1st item is 0 or a 1 with a ListBox. 
        For index = 0 To objData.objReturnData.Count
            myControl.SelectedIndex = index
            myControl.SelectedValue = objData.objReturnData(index)

           ' aAgencyList(index, index) = objData.FetchActiveAgencies
           'lstAgency.Item(index) = aAgencyList(index, index)
        Next


        'Login1.Controls.Item(0).datasource = aAgencyList
        'Login1.Controls.Item(0).TemplateSourceDirectory(aAgencyList)
        'Login1.Controls.Item(0) = aAgencyList

        Login1.Controls.Item(0).DataBind()


    End Sub


To achieve the above the DataManager Class now looks like.>>
The added lines are highlighted as.>>
'The following line was added.
The reason being is i wanted to make the arraylist "PUBLIC" so it can be seen by the Login.aspx.vb code as arraylist objReturnData

Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.SqlClient
Imports System.Security.Cryptography
Imports System.Text
Imports System.Data.SqlTypes
Imports System.Configuration.ConfigurationManager
Imports System


Public Class DataManager

#Region " PUBLIC PROPERTIES AND METHODS "
    Public ReadOnly Property ConnectionString() As String
        Get
            ConnectionString = _ConnectionString
        End Get
    End Property
#End Region


#Region " PRIVATE PROPERTIES AND METHODS "
    Private conSQL As SqlConnection
    Private cmdSQL As SqlCommand
    Private _ConnectionString As String
'The following line was added.
    Public objReturnData As ArrayList


    Private Function FormatSingleQuotes(ByVal inString As String) As String
        Try
            Dim strReturn As String
            Dim intLastLocation As Integer

            strReturn = inString
            intLastLocation = 0
            Do While InStr(intLastLocation + 1, strReturn, "'") > 0 And Mid(strReturn, InStr(intLastLocation + 1, strReturn, "'") + 1, 1) <> "'"
                strReturn = Left(strReturn, InStr(intLastLocation + 1, strReturn, "'")) & "'" & Mid(strReturn, InStr(intLastLocation + 1, strReturn, "'") + 1)
                intLastLocation = InStr(intLastLocation + 1, strReturn, "'") + 1
            Loop

            Return strReturn
        Catch ex As Exception
            Return inString
        End Try

    End Function

    Function ToHexString(ByVal bytes() As Byte) As String
        Dim hexDigits As Char() = {"0"c, "1"c, "2"c, "3"c, "4"c, _
                           "5"c, "6"c, "7"c, "8"c, "9"c, _
                           "A"c, "B"c, "C"c, "D"c, "E"c, "F"c}
        Dim chars(bytes.Length * 2) As Char
        Dim i As Integer

        For i = 0 To bytes.Length - 1
            Dim b As Integer = bytes(i)
            chars((i * 2)) = hexDigits(b >> 4)
            chars((i * 2) + 1) = hexDigits(b And &HF)
        Next i
        Return New String(chars)
    End Function


#End Region


    Public Function FetchActiveAgencies() As ArrayList
        Dim dsData As SqlDataReader
        Dim objReturn As New ArrayList

        Dim AgencyID As String
        Dim Name As String

        'cmdSQL.CommandText = "SELECT AgencyID, AgencyName FROM BMS.dbo.Agency WHERE Active = 1 ORDER BY AgencyName"
        'dsData = cmdSQL.ExecuteReader
        'Do While dsData.Read = True
        '    objReturn.Add(New Agency(Val(dsData.GetValue(0).ToString), dsData.GetValue(1).ToString))
        'Loop


        Dim Agency As New Agency(1, "Item One")
        Name = Agency.GetName(Name)
        objReturn.Add(New Agency((Agency.GetAgencyID(AgencyID)), (Agency.GetName(Name))))
        Agency.AddAgency(2, "Item Two")
        Name = Agency.GetName(Name)
        objReturn.Add(New Agency((Agency.GetAgencyID(AgencyID)), (Agency.GetName(Name))))
        Agency.AddAgency(3, "Item Three")
        Name = Agency.GetName(Name)
        objReturn.Add(New Agency((Agency.GetAgencyID(AgencyID)), (Agency.GetName(Name))))
        Agency.AddAgency(4, "Item Four")
        Name = Agency.GetName(Name)
        objReturn.Add(New Agency((Agency.GetAgencyID(AgencyID)), (Agency.GetName(Name))))


        '    dsData.Close()
        dsData = Nothing
'The following line was added.
        objReturnData = objReturn
        Return objReturn
    End Function


    ' PASSWORD CHECKERS
    Public Function CheckInitPassword(ByVal UserLogin As String, ByVal Password As String) As Integer
        Dim initReturn As Boolean
        Dim hashedBytes As Byte()
        Dim encoder As New UTF8Encoding()
        Dim md5Hasher As New MD5CryptoServiceProvider()
        Dim UserIDPassword As String
        Dim InitHashedPassword As Byte()
        Dim UserIDInitialPW As String
        Dim initialPassword As String
        Dim enteredPassword As String

        UserIDPassword = UserLogin.ToUpper & Password
        hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(UserIDPassword))
        enteredPassword = Me.ToHexString(hashedBytes)

        UserIDInitialPW = UserLogin.ToUpper & "password"
        InitHashedPassword = md5Hasher.ComputeHash(encoder.GetBytes(UserIDInitialPW))
        initialPassword = Me.ToHexString(InitHashedPassword)
        If enteredPassword = initialPassword Then
            initReturn = True
        End If

        Return initReturn

    End Function

    Public Function CheckUserPassword(ByVal UserLogin As String, ByVal Password As String) As Integer
        'Dim objData As DataManager
        Dim objReturn As AgencyUser
        Dim intReturn As Integer
        Dim drReturn As SqlDataReader
        Dim hashedBytes As Byte()
        Dim encoder As New UTF8Encoding()
        Dim md5Hasher As New MD5CryptoServiceProvider()
        Dim UserIDPassword As String
        Dim enteredPassword As String
        Dim DBPassword As String

        UserIDPassword = UserLogin.ToUpper & Password
        hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(UserIDPassword))
        enteredPassword = Me.ToHexString(hashedBytes)


        cmdSQL.CommandText = "SELECT Agency_UserID, FirstName, LastName, LoginID, LoginPassword, Email, Active, AgencyID FROM BMS.dbo.AgencyUsers WHERE UPPER(LoginID) = '" & UserLogin.ToUpper & "' "
        drReturn = cmdSQL.ExecuteReader
        If drReturn.Read = True Then
            objReturn = New AgencyUser(Val(drReturn.GetValue(0).ToString), drReturn.GetValue(1).ToString, _
                    drReturn.GetValue(2).ToString, drReturn.GetValue(3).ToString, drReturn.GetValue(4), _
                    drReturn.GetValue(5).ToString, CBool(drReturn.GetValue(6).ToString), drReturn.GetValue(7).ToString)
            DBPassword = Me.ToHexString(objReturn.LoginPassword)

            If enteredPassword = DBPassword Then
                intReturn = CInt(drReturn.GetValue(0).ToString)
            Else
                intReturn = -1
            End If
        Else
            intReturn = -1
        End If

        drReturn.Close()
        drReturn = Nothing
        Return intReturn

    End Function


#Region " CONSTRUCTORS AND DESTRUCTORS "
    Public Sub New(ByVal DatabaseServer As String, ByVal DatabaseCatalog As String, _
                     ByVal DatabaseUsername As String, ByVal DatabasePassword As String)
        _ConnectionString = "Persist Security Info=False;User ID=" & DatabaseUsername & ";Initial Catalog=" & DatabaseCatalog & ";Data Source=" & DatabaseServer & ";Packet Size=4096;Password=" & DatabasePassword
        conSQL = New SqlConnection(_ConnectionString)
        'conSQL.Open()
        'cmdSQL = New SqlCommand
        'cmdSQL.Connection = conSQL
    End Sub

    Public Sub Dispose()
        conSQL.Close()
        cmdSQL = Nothing
        conSQL = Nothing
    End Sub
#End Region


End Class


This seems a bit further forward?

Regards,

Dr M.
Report
Re: Tried but still have error Posted by simmonsl on 21 Dec 2006 at 2:33 PM
This message was edited by simmonsl at 2006-12-21 14:53:18

: This message was edited by DrMarten at 2006-12-21 8:10:25

: Hi,
:
: 2nd line in DataManager.Vb in function CheckUserPassword
: has AgencyUser as an undefined type. The line is>>
: Dim objReturn As AgencyUser
:
:
:  Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load
:         'Dim aAgencyList As New ArrayList
: 
:         If Request.QueryString("LO") = "True" Then
:             Session.Clear()
:         End If
: 
: 
:         objData = New DataManager(ConfigurationManager.AppSettings("DatabaseServer"), _
:           ConfigurationManager.AppSettings("DatabaseCatalog"), ConfigurationManager.AppSettings("DatabaseUsername"), _
:           ConfigurationManager.AppSettings("DatabasePassword"))
: 
: ' I've added the following to populate your listbox
: ' from your FetchActiveAgencies function.
:         Dim index As Integer
:         Dim myControl As ListBox
:         myControl = Me.FindControl("lstAgency")
:         myControl.SelectionMode = ListSelectionMode.Single
: 'This loop may need to start with a 1.
: ' I can't remember whether 1st item is 0 or a 1 with a ListBox. 
:         For index = 0 To objData.objReturnData.Count
:             myControl.SelectedIndex = index
:             myControl.SelectedValue = objData.objReturnData(index)
: 
:            ' aAgencyList(index, index) = objData.FetchActiveAgencies
:            'lstAgency.Item(index) = aAgencyList(index, index)
:         Next
: 
: 
:         'Login1.Controls.Item(0).datasource = aAgencyList
:         'Login1.Controls.Item(0).TemplateSourceDirectory(aAgencyList)
:         'Login1.Controls.Item(0) = aAgencyList
: 
:         Login1.Controls.Item(0).DataBind()
: 
: 
:     End Sub
: 

:
: To achieve the above the DataManager Class now looks like.>>
: The added lines are highlighted as.>>
: 'The following line was added.
: The reason being is i wanted to make the arraylist "PUBLIC" so it can be seen by the Login.aspx.vb code as arraylist objReturnData
:
:
: Imports Microsoft.VisualBasic
: Imports System.Data
: Imports System.Data.SqlClient
: Imports System.Security.Cryptography
: Imports System.Text
: Imports System.Data.SqlTypes
: Imports System.Configuration.ConfigurationManager
: Imports System
: 
: 
: Public Class DataManager
: 
: #Region " PUBLIC PROPERTIES AND METHODS "
:     Public ReadOnly Property ConnectionString() As String
:         Get
:             ConnectionString = _ConnectionString
:         End Get
:     End Property
: #End Region
: 
: 
: #Region " PRIVATE PROPERTIES AND METHODS "
:     Private conSQL As SqlConnection
:     Private cmdSQL As SqlCommand
:     Private _ConnectionString As String
: 'The following line was added.
:     Public objReturnData As ArrayList
: 
: 
:     Private Function FormatSingleQuotes(ByVal inString As String) As String
:         Try
:             Dim strReturn As String
:             Dim intLastLocation As Integer
: 
:             strReturn = inString
:             intLastLocation = 0
:             Do While InStr(intLastLocation + 1, strReturn, "'") > 0 And Mid(strReturn, InStr(intLastLocation + 1, strReturn, "'") + 1, 1) <> "'"
:                 strReturn = Left(strReturn, InStr(intLastLocation + 1, strReturn, "'")) & "'" & Mid(strReturn, InStr(intLastLocation + 1, strReturn, "'") + 1)
:                 intLastLocation = InStr(intLastLocation + 1, strReturn, "'") + 1
:             Loop
: 
:             Return strReturn
:         Catch ex As Exception
:             Return inString
:         End Try
: 
:     End Function
: 
:     Function ToHexString(ByVal bytes() As Byte) As String
:         Dim hexDigits As Char() = {"0"c, "1"c, "2"c, "3"c, "4"c, _
:                            "5"c, "6"c, "7"c, "8"c, "9"c, _
:                            "A"c, "B"c, "C"c, "D"c, "E"c, "F"c}
:         Dim chars(bytes.Length * 2) As Char
:         Dim i As Integer
: 
:         For i = 0 To bytes.Length - 1
:             Dim b As Integer = bytes(i)
:             chars((i * 2)) = hexDigits(b >> 4)
:             chars((i * 2) + 1) = hexDigits(b And &HF)
:         Next i
:         Return New String(chars)
:     End Function
: 
: 
: #End Region
: 
: 
:     Public Function FetchActiveAgencies() As ArrayList
:         Dim dsData As SqlDataReader
:         Dim objReturn As New ArrayList
: 
:         Dim AgencyID As String
:         Dim Name As String
: 
:         'cmdSQL.CommandText = "SELECT AgencyID, AgencyName FROM BMS.dbo.Agency WHERE Active = 1 ORDER BY AgencyName"
:         'dsData = cmdSQL.ExecuteReader
:         'Do While dsData.Read = True
:         '    objReturn.Add(New Agency(Val(dsData.GetValue(0).ToString), dsData.GetValue(1).ToString))
:         'Loop
: 
: 
:         Dim Agency As New Agency(1, "Item One")
:         Name = Agency.GetName(Name)
:         objReturn.Add(New Agency((Agency.GetAgencyID(AgencyID)), (Agency.GetName(Name))))
:         Agency.AddAgency(2, "Item Two")
:         Name = Agency.GetName(Name)
:         objReturn.Add(New Agency((Agency.GetAgencyID(AgencyID)), (Agency.GetName(Name))))
:         Agency.AddAgency(3, "Item Three")
:         Name = Agency.GetName(Name)
:         objReturn.Add(New Agency((Agency.GetAgencyID(AgencyID)), (Agency.GetName(Name))))
:         Agency.AddAgency(4, "Item Four")
:         Name = Agency.GetName(Name)
:         objReturn.Add(New Agency((Agency.GetAgencyID(AgencyID)), (Agency.GetName(Name))))
: 
: 
:         '    dsData.Close()
:         dsData = Nothing
: 'The following line was added.
:         objReturnData = objReturn
:         Return objReturn
:     End Function
: 
: 
:     ' PASSWORD CHECKERS
:     Public Function CheckInitPassword(ByVal UserLogin As String, ByVal Password As String) As Integer
:         Dim initReturn As Boolean
:         Dim hashedBytes As Byte()
:         Dim encoder As New UTF8Encoding()
:         Dim md5Hasher As New MD5CryptoServiceProvider()
:         Dim UserIDPassword As String
:         Dim InitHashedPassword As Byte()
:         Dim UserIDInitialPW As String
:         Dim initialPassword As String
:         Dim enteredPassword As String
: 
:         UserIDPassword = UserLogin.ToUpper & Password
:         hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(UserIDPassword))
:         enteredPassword = Me.ToHexString(hashedBytes)
: 
:         UserIDInitialPW = UserLogin.ToUpper & "password"
:         InitHashedPassword = md5Hasher.ComputeHash(encoder.GetBytes(UserIDInitialPW))
:         initialPassword = Me.ToHexString(InitHashedPassword)
:         If enteredPassword = initialPassword Then
:             initReturn = True
:         End If
: 
:         Return initReturn
: 
:     End Function
: 
:     Public Function CheckUserPassword(ByVal UserLogin As String, ByVal Password As String) As Integer
:         'Dim objData As DataManager
:         Dim objReturn As AgencyUser
:         Dim intReturn As Integer
:         Dim drReturn As SqlDataReader
:         Dim hashedBytes As Byte()
:         Dim encoder As New UTF8Encoding()
:         Dim md5Hasher As New MD5CryptoServiceProvider()
:         Dim UserIDPassword As String
:         Dim enteredPassword As String
:         Dim DBPassword As String
: 
:         UserIDPassword = UserLogin.ToUpper & Password
:         hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(UserIDPassword))
:         enteredPassword = Me.ToHexString(hashedBytes)
: 
: 
:         cmdSQL.CommandText = "SELECT Agency_UserID, FirstName, LastName, LoginID, LoginPassword, Email, Active, AgencyID FROM BMS.dbo.AgencyUsers WHERE UPPER(LoginID) = '" & UserLogin.ToUpper & "' "
:         drReturn = cmdSQL.ExecuteReader
:         If drReturn.Read = True Then
:             objReturn = New AgencyUser(Val(drReturn.GetValue(0).ToString), drReturn.GetValue(1).ToString, _
:                     drReturn.GetValue(2).ToString, drReturn.GetValue(3).ToString, drReturn.GetValue(4), _
:                     drReturn.GetValue(5).ToString, CBool(drReturn.GetValue(6).ToString), drReturn.GetValue(7).ToString)
:             DBPassword = Me.ToHexString(objReturn.LoginPassword)
: 
:             If enteredPassword = DBPassword Then
:                 intReturn = CInt(drReturn.GetValue(0).ToString)
:             Else
:                 intReturn = -1
:             End If
:         Else
:             intReturn = -1
:         End If
: 
:         drReturn.Close()
:         drReturn = Nothing
:         Return intReturn
: 
:     End Function
: 
: 
: #Region " CONSTRUCTORS AND DESTRUCTORS "
:     Public Sub New(ByVal DatabaseServer As String, ByVal DatabaseCatalog As String, _
:                      ByVal DatabaseUsername As String, ByVal DatabasePassword As String)
:         _ConnectionString = "Persist Security Info=False;User ID=" & DatabaseUsername & ";Initial Catalog=" & DatabaseCatalog & ";Data Source=" & DatabaseServer & ";Packet Size=4096;Password=" & DatabasePassword
:         conSQL = New SqlConnection(_ConnectionString)
:         'conSQL.Open()
:         'cmdSQL = New SqlCommand
:         'cmdSQL.Connection = conSQL
:     End Sub
: 
:     Public Sub Dispose()
:         conSQL.Close()
:         cmdSQL = Nothing
:         conSQL = Nothing
:     End Sub
: #End Region
: 
: 
: End Class
: 

:
: This seems a bit further forward?
:
: Regards,
:
: Dr M.
:
**********************************************************************

First, I want to thank you again for your time. I just don't want this thing to beat me. There is a defined AgencyUser class but since we don't go that far I did'nt include it yesterday.

I have worked with what you gave me. I have even explored the list of available members. I have imported "System.Web.UI.WebControls". Below is the Page_Load code with comments on messages or values returned.
______________________________________________________________________
Imports System.Data.SqlClient
Imports System.Web.UI.WebControls

Partial Class Login
Inherits System.Web.UI.Page
Dim objData As DataManager
_______________________________________________________________________

Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load
Dim aAgencyList As New ArrayList

If Request.QueryString("LO") = "True" Then
Session.Clear()
End If

objData = New DataManager(ConfigurationManager.AppSettings("DatabaseServer"), _
ConfigurationManager.AppSettings("DatabaseCatalog"), ConfigurationManager.AppSettings("DatabaseUsername"), _
ConfigurationManager.AppSettings("DatabasePassword"))

' aAgencyList = objData.objReturnData . . . (Returned Nothing)
aAgencyList = objData.FetchActiveAgencies

Dim index As Integer = 0
Dim myControl As ListBox
myControl = Me.FindControl("lstAgency")
'Above returns nothing

Try
myControl.SelectionMode = ListSelectionMode.Single
Catch ex As Exception
''''' gets a Null Exception
End Try

'For index = 0 To aAgencyList(index)
' myControl.SelectedIndex = index
' myControl.SelectedValue = aAgencyList(index)
'Next

Login1.Controls.Item(0).DataBind()


End Sub





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.