Welcome To My Latest Tutorial With Visual Basic 2010
MySQL Login (with progressbar)
NOTE: The Codes In This Tutorial Are Codes That I Have Gathered Through Diffrent Source(s).
Also There Are Loads Of People Asking About These Features Here On HF So This Has Gave Me The Idea To Write This Tutorial.
---------------------------------
Download MySql Connector Here: DOWNLOAD
--------------
Form 1 Code:
--------------
Add The MySql.Data.dll To Your Project (Project>Add Reference>Browse>C:\Program Files\MySQL\MySQL Connector Net 6.4.3\Assemblies\v4.0\MySql.Data.dll)
Add: 2 Labels(username, password), 2 Textbox's(username, password), 1 Timer, 1 ProgressBar, 2 Buttons(login, exit).
Set Timer1's Properties To Enabled:False & Interval:100
Double Click Your Form To Bring Up The Source And Paste This Code In (Replace "server=yourserver.com; Port=3306; user id=username; password=password; database=database" And "Dim sqlquary = "SELECT From database WHERE Username='" & TextBox1.Text & "'AND Password='" & TextBox2.Text & "';"" Explained Below)
---------------
Database Tips:
---------------
To Setup A Free Database With db4free.net For This Tutorial Simply Register Then Log In And Create A New Table Called "login" Without Quotes With 3 Columns.
Column 1 Name: ID, Type: INT, Length/Values: 155, Index: Primary, A_I: Checked
Column 2 Name: Username, Type: TEXT, Length/Values: 25
Column 3 Name: Password, Type: TEXT, Length/Values: 25
Where Does All This Information Go? Remember At The Top I Told You To Rename Some Things To Your Info Well I'l Help You Out With That Now,
Ok Just Say My Username On db4free.net Was "tutorial" And My Password Was "changeme" And The Table I Created Was As Above "login" Then I Would Set My MySql Connectionstring As:
server=db4free.net; Port=3306; user id=tutorial; password=changeme; database=tutorial
Dim sqlquary = "SELECT From login WHERE Username='" & TextBox1.Text & "'AND Password='" & TextBox2.Text & "';"
-----------------------------
I Hope This Tutorial Was Explained Enough And Also Helped Some Of You With Your Questions.
I Will Not Stop Writing Tutorials As I Love Helping People.
Thanks For Reading :)
MySQL Login (with progressbar)
NOTE: The Codes In This Tutorial Are Codes That I Have Gathered Through Diffrent Source(s).
Also There Are Loads Of People Asking About These Features Here On HF So This Has Gave Me The Idea To Write This Tutorial.
---------------------------------
Download MySql Connector Here: DOWNLOAD
--------------
Form 1 Code:
--------------
Add The MySql.Data.dll To Your Project (Project>Add Reference>Browse>C:\Program Files\MySQL\MySQL Connector Net 6.4.3\Assemblies\v4.0\MySql.Data.dll)
Add: 2 Labels(username, password), 2 Textbox's(username, password), 1 Timer, 1 ProgressBar, 2 Buttons(login, exit).
Set Timer1's Properties To Enabled:False & Interval:100
Double Click Your Form To Bring Up The Source And Paste This Code In (Replace "server=yourserver.com; Port=3306; user id=username; password=password; database=database" And "Dim sqlquary = "SELECT From database WHERE Username='" & TextBox1.Text & "'AND Password='" & TextBox2.Text & "';"" Explained Below)
Code
Imports System.Data.SqlClient
Imports MySql.Data.MySqlClient
Public Class Form1
Dim MySqlConnection As MySqlConnection
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MySqlConnection = New MySqlConnection
MySqlConnection.ConnectionString = "server=yourserver.com; Port=3306; user id=username; password=password; database=database"
MySqlConnection.Open()
Dim Myadapter As New MySqlDataAdapter
Dim sqlquary = "SELECT * From database WHERE Username='" & TextBox1.Text & "'AND Password='" & TextBox2.Text & "';"
Dim command As New MySqlCommand
command.Connection = MySqlConnection
command.CommandText = sqlquary
Myadapter.SelectCommand = command
Dim Mydata As MySqlDataReader
Mydata = command.ExecuteReader
If Mydata.HasRows = 0 Then
MsgBox("Error Wrong Login Information", MsgBoxStyle.Exclamation)
Else
Timer1.Start()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ProgressBar1.Increment(1)
If ProgressBar1.Value = ProgressBar1.Maximum Then
MsgBox("Logged In")
End If
End Sub
End Class---------------
Database Tips:
---------------
To Setup A Free Database With db4free.net For This Tutorial Simply Register Then Log In And Create A New Table Called "login" Without Quotes With 3 Columns.
Column 1 Name: ID, Type: INT, Length/Values: 155, Index: Primary, A_I: Checked
Column 2 Name: Username, Type: TEXT, Length/Values: 25
Column 3 Name: Password, Type: TEXT, Length/Values: 25
Where Does All This Information Go? Remember At The Top I Told You To Rename Some Things To Your Info Well I'l Help You Out With That Now,
Ok Just Say My Username On db4free.net Was "tutorial" And My Password Was "changeme" And The Table I Created Was As Above "login" Then I Would Set My MySql Connectionstring As:
server=db4free.net; Port=3306; user id=tutorial; password=changeme; database=tutorial
Dim sqlquary = "SELECT From login WHERE Username='" & TextBox1.Text & "'AND Password='" & TextBox2.Text & "';"
-----------------------------
I Hope This Tutorial Was Explained Enough And Also Helped Some Of You With Your Questions.
I Will Not Stop Writing Tutorials As I Love Helping People.
Thanks For Reading :)


![[Image: gh_banner.png]](https://hexui.com/asset/img/gh_banner.png)

![[Image: MW3lGyc.png]](https://i.imgur.com/MW3lGyc.png)