I am getting problem with brandonio's registration 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 problem with brandonio's registration form... (/showthread.php?tid=768) |
I am getting problem with brandonio's registration form... - mnxford - 03-26-2013 hello guys, Following the tutorials of brandonio i made a registration form and tried to give some additional features to it. Here the code of the registration form: [code2=vbnet]Imports System.Windows.Forms Imports MySql.Data.MySqlClient Public Class registrationForm Public conn As MySqlConnection Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click conn = New MySqlConnection(ServerString) '/ Username existing verification If tbx_username.Text = Nothing Or tbx_password.Text = Nothing Or tbx_conPassword.Text = Nothing Or tbx_email.Text = Nothing Or tbx_realname.Text = Nothing Then MsgBox("Please fill up all the fields.", MsgBoxStyle.Information, "Error") Else Dim Username As Boolean = True Dim Email As Boolean = True conn.Open() Dim sqlquery As String = "SELECT * FROM reg_members WHERE Username = '" & tbx_username.Text & "';" 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 MsgBox("Username is already in use!", MsgBoxStyle.Exclamation, "Error") Username = False data.Close() Else data.Close() Username = True End If End While data.Close() '/ Email existing verification Dim sqlquery2 As String = "SELECT * FROM reg_members WHERE Email = '" & tbx_email.Text & "';" Dim data2 As MySqlDataReader Dim adapter2 As New MySqlDataAdapter Dim command2 As New MySqlCommand command2.CommandText = sqlquery2 command2.Connection = conn adapter2.SelectCommand = command2 data2 = command2.ExecuteReader While data2.Read() If data2.HasRows() = True Then MsgBox("Email is already in use!", MsgBoxStyle.Exclamation, "Error") Email = False data2.Close() Else data2.Close() Email = True End If End While data2.Close() '/ Data entry section If Not tbx_conPassword.Text = tbx_password.Text Then MsgBox("Password doesn't match!", MsgBoxStyle.Critical, "Error") Else If Username = True And Email = True Then Dim sqlquery3 As String = "INSERT INTO reg_members (Username, Password, Email, FullName)VALUES ('" & tbx_username.Text & "','" & tbx_password.Text & "','" & tbx_email.Text & "','" & tbx_realname.Text & "')" Dim data3 As MySqlDataReader Dim adapter3 As New MySqlDataAdapter Dim command3 As New MySqlCommand command3.CommandText = sqlquery3 command3.Connection = conn adapter3.SelectCommand = command3 data3 = command3.ExecuteReader MsgBox("You have successfully registered! Now you can log in.", MsgBoxStyle.Information, "Registration Successful") Me.Close() loginForm.Show() End If End If End If End Sub Private Sub tbx_conPassword_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbx_conPassword.TextChanged If Not tbx_conPassword.Text = tbx_password.Text Then Label8.Text = "Password doesn't match." Else Label8.Text = "" End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.Close() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click tbx_username.Clear() tbx_password.Clear() tbx_conPassword.Clear() tbx_email.Clear() tbx_realname.Clear() End Sub End Class[/code2] I have added the features to say email already exist as the login form already says that username already exist...but it works only for the username but not for the email address....after trying the code it gives an error of db conn close needed or open neeede or already opened such type of errors... Please help me how can I solve this problem and what is the solved code.Please provide me the correction of this code... Brandonio bro needs your help..... Thanks in advance....... Re: I am getting problem with brandonio's registration form. - mnxford - 03-27-2013 somebody please help me in this matter... Brandonio bro where are u???? |