BP Forums
i am getting a problem with brandonio's login form - Printable Version

+- BP Forums (https://bpforums.info)
+-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55)
+--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56)
+---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8)
+----- Forum: Programming Help (https://bpforums.info/forumdisplay.php?fid=9)
+----- Thread: i am getting a problem with brandonio's login form (/showthread.php?tid=767)



i am getting a problem with brandonio's login form - mnxford - 03-26-2013

hello guys,

Following the tutorials of brandonio i made a login form and tried to give some additional features to it.

Here the code of the login form:
Code:
Imports MySql.Data.MySqlClient
Public Class loginForm
    Public conn As MySqlConnection

    Private Sub loginButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles loginButton.Click
        conn = New MySqlConnection(ServerString)
        Select Case ComboBox1.Text
            Case "Normal Member"
                If txtUsername.Text = Nothing Or txtPassword.Text = Nothing Then
                    MsgBox("Please fill up all the fields.", MsgBoxStyle.Information, "Error")
                Else
                    Me.Cursor = Cursors.AppStarting
                    Try
                        conn.Open()
                        Dim sqlquery As String = "SELECT * FROM reg_members"
                        Dim data As MySqlDataReader
                        Dim adapter As New MySqlDataAdapter
                        Dim command As New MySqlCommand
                        command.CommandText = sqlquery
                        command.Connection = conn
                        adapter.SelectCommand = command
                        data = command.ExecuteReader
                        While data.Read()
                            If data.HasRows() = True Then
                                If Not data(1).ToString = txtUsername.Text Then
                                    MsgBox("Login Failed. Account doesn't exist. Please register to log in.", MsgBoxStyle.Critical, "Error")
                                Else
                                    If data(2).ToString = txtPassword.Text Then
                                        MsgBox("You have successfully logged in.", MsgBoxStyle.Information, "Login Successful")
                                        Me.Close()
                                        normalMemberForm.Show()
                                    Else
                                        MsgBox("Login Failed. Incorrect password. Please try again.", MsgBoxStyle.Critical, "Error")
                                    End If
                                End If
                            Else
                                MsgBox("Login Failed. Incorrect password. Please try again.", MsgBoxStyle.Critical, "Error")
                            End If
                        End While
                    Catch ex As Exception
                    End Try
                End If
            Case "Official Member"
                If txtUsername.Text = Nothing Or txtPassword.Text = Nothing Then
                    MsgBox("Please fill up all the fields.", MsgBoxStyle.Information, "Error")
                Else
                    Me.Cursor = Cursors.AppStarting
                    Try
                        conn.Open()
                        Dim sqlquery As String = "SELECT * FROM off_members"
                        Dim data As MySqlDataReader
                        Dim adapter As New MySqlDataAdapter
                        Dim command As New MySqlCommand
                        command.CommandText = sqlquery
                        command.Connection = conn
                        adapter.SelectCommand = command
                        data = command.ExecuteReader
                        While data.Read()
                            If data.HasRows() = True Then
                                If Not data(1).ToString = txtUsername.Text Then
                                    MsgBox("Login Failed. Account doesn't exist. Please register to log in.", MsgBoxStyle.Critical, "Error")
                                Else
                                    If data(2).ToString = txtPassword.Text Then
                                        MsgBox("You have successfully logged in.", MsgBoxStyle.Information, "Login Successful")
                                        Me.Close()
                                        officialMemberForm.Show()
                                    Else
                                        MsgBox("Login Failed. Incorrect password. Please try again.", MsgBoxStyle.Critical, "Error")
                                    End If
                                End If
                            Else
                                MsgBox("Login Failed. Incorrect password. Please try again.", MsgBoxStyle.Critical, "Error")
                            End If
                        End While
                    Catch ex As Exception
                    End Try
                End If
        End Select
    End Sub

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        Me.Close()
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        loginButton.Enabled = True
        loginButton.Select()
    End Sub
End Class

I have added the features to say the user doesn't exist in the login form....but it works great with the off_members but when using the reg_members after login i get the error of user doesn't exist many times....

Please help me how can I solve this problem and what is the solved code.....

Brandonio bro needs your help.....


Re: i am getting a problem with brandonio's login form - mnxford - 03-27-2013

somebody please help me in this matter...

Brandonio bro where are u????