Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
i am getting a problem with brandonio's login form
#1
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.....
#2
somebody please help me in this matter...

Brandonio bro where are u????


Possibly Related Threads…
Thread Author Replies Views Last Post
  I am getting problem with brandonio's registration form... mnxford 1 9,172 03-27-2013, 10:55 AM
Last Post: mnxford
  How do I fill my form with MySQL data based on Combobox? kismetgerald 8 26,714 10-14-2012, 09:05 PM
Last Post: brandonio21
  getting a file name form a save dialoge zmanalpha 3 14,117 08-04-2012, 03:15 PM
Last Post: brandonio21
  making a windows login system Bradley 3 13,890 05-29-2012, 04:47 PM
Last Post: brandonio21
  Form/Application Store PsychicShadow 2 12,422 06-02-2011, 09:16 PM
Last Post: xolara
  Problem with Syntax Highlighting? brandonio21 2 12,730 04-02-2011, 10:37 PM
Last Post: brandonio21

Forum Jump:


Users browsing this thread: 1 Guest(s)