Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports Microsoft.VisualBasic.FileIO.FileSystem
- Imports Microsoft.VisualBasic.FileIO.SpecialDirectories
- Imports MySql.Data.MySqlClient
- Imports MySql.Data.Types
- Imports MySql.Web.Common
- Public Class Register
- Private Sub Register_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- TextBox1.Text = Nothing
- TextBox2.Text = Nothing
- Login.Show()
- Me.Close()
- End Sub
- Public conn As MySqlConnection
- Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
- If TextBox2.Text = TextBox3.Text = True Then
- conn = New MySqlConnection("server=server.net;Port=3306; user id=sqluser; password=sqlpass; database=Users")
- Dim username As Boolean = True
- conn.Open()
- Dim sqlquery As String = "SELECT * FROM Users WHERE Username = '" & TextBox1.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 Already in use!")
- username = False
- data.Close()
- Else
- data.Close()
- username = True
- End If
- End While
- data.Close()
- If username = True Then
- Dim sqlquery2 As String = "INSERT INTO Users (Username, Password)VALUES ('" & TextBox1.Text & "','" & TextBox2.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
- MsgBox("You've Registered!")
- Login.Show()
- End If
- End If
- If TextBox2.Text = TextBox3.Text = False Then
- MsgBox("Password fields not matching")
- End If
- Me.Close()
- End Sub
- End Class
Add Comment
Please, Sign In to add comment