Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

dataSource for login template

simmonslsimmonsl Posts: 9Member
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


Comments

  • DrMartenDrMarten Posts: 748Member
    [b][red]This message was edited by DrMarten at 2006-12-20 5:24:35[/red][/b][hr]
    : 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.
  • simmonslsimmonsl Posts: 9Member
    : [b][red]This message was edited by DrMarten at 2006-12-20 5:24:35[/red][/b][hr]
    : : 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
  • DrMartenDrMarten Posts: 748Member
    [b][red]This message was edited by DrMarten at 2006-12-20 9:23:59[/red][/b][hr]
    : : : 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 [b][red]and i'll see what i can do.[/b][/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.
    [b][blue]
    Alternatively drop one of the datasource controls on your FORM/PAGE from the toolbox data area.
    Select from;
    [red]
    SqlDataSource
    AccessDataSource
    ObjectDataSource
    XMLDataSource or
    SiteMapDataSource
    [/red]
    [/blue][/b]


    Regards,

    Dr M.

  • DrMartenDrMarten Posts: 748Member
    [b][red]This message was edited by DrMarten at 2006-12-21 8:10:25[/red][/b][hr]
    Hi,

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

    [code]
    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"))
    [b]
    [green]' I've added the following to populate your listbox
    ' from your FetchActiveAgencies function.[/green]
    Dim index As Integer
    Dim myControl As ListBox
    myControl = Me.FindControl("lstAgency")
    myControl.SelectionMode = ListSelectionMode.Single
    [green]'This loop may need to start with a 1.
    ' I can't remember whether 1st item is 0 or a 1 with a ListBox. :-)[/green]
    For index = 0 To objData.objReturnData.Count
    myControl.SelectedIndex = index
    myControl.SelectedValue = objData.objReturnData(index)
    [green]
    ' aAgencyList(index, index) = objData.FetchActiveAgencies
    'lstAgency.Item(index) = aAgencyList(index, index)[/green]
    Next
    [/b]

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

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


    End Sub
    [/code]

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

    [code]
    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
    [b][red]'The following line was added.[/red][/b]
    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
    [b][red]'The following line was added.[/red][/b]
    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
    [/code]

    This seems a bit further forward?

    Regards,

    Dr M.
  • DrMartenDrMarten Posts: 748Member
    [b][red]This message was edited by DrMarten at 2006-12-21 8:31:31[/red][/b][hr]
    Hi,

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

    [code]
    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
    [/code]



    Regards,

    Dr M.

  • simmonslsimmonsl Posts: 9Member
    [b][red]This message was edited by simmonsl at 2006-12-21 14:53:18[/red][/b][hr]
    : [b][red]This message was edited by DrMarten at 2006-12-21 8:10:25[/red][/b][hr]
    : Hi,
    :
    : 2nd line in DataManager.Vb in function CheckUserPassword
    : has [b]AgencyUser[/b] as an undefined type. The line is>>
    : Dim objReturn As AgencyUser
    :
    : [code]
    : 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"))
    : [b]
    : [green]' I've added the following to populate your listbox
    : ' from your FetchActiveAgencies function.[/green]
    : Dim index As Integer
    : Dim myControl As ListBox
    : myControl = Me.FindControl("lstAgency")
    : myControl.SelectionMode = ListSelectionMode.Single
    : [green]'This loop may need to start with a 1.
    : ' I can't remember whether 1st item is 0 or a 1 with a ListBox. :-)[/green]
    : For index = 0 To objData.objReturnData.Count
    : myControl.SelectedIndex = index
    : myControl.SelectedValue = objData.objReturnData(index)
    : [green]
    : ' aAgencyList(index, index) = objData.FetchActiveAgencies
    : 'lstAgency.Item(index) = aAgencyList(index, index)[/green]
    : Next
    : [/b]
    :
    : 'Login1.Controls.Item(0).datasource = aAgencyList
    : 'Login1.Controls.Item(0).TemplateSourceDirectory(aAgencyList)
    : 'Login1.Controls.Item(0) = aAgencyList
    :
    : Login1.Controls.Item(0).DataBind()
    :
    :
    : End Sub
    : [/code]
    :
    : To achieve the above the DataManager Class now looks like.>>
    : The added lines are highlighted as.>>
    : [b][red]'The following line was added.[/red][/b]
    : The reason being is i wanted to make the arraylist "PUBLIC" so it can be seen by the Login.aspx.vb code as arraylist [b]objReturnData[/b]
    :
    : [code]
    : 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
    : [b][red]'The following line was added.[/red][/b]
    : 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
    : [b][red]'The following line was added.[/red][/b]
    : 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
    : [/code]
    :
    : 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


Sign In or Register to comment.