Monday, February 8, 2021

Login System in VB.NET and MySQL

 I wrote this program that will ask the user to give username and password to check if the user is valid user or not the system using VB.NET and MySQL.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City I also accepting computer repair, networking, and Arduino Project development at a very affordable price. My website is www.jakerpomperada.blogspot.com and www.jakerpomperada.com

If you like this video please click the LIKE button, SHARE, and SUBSCRIBE to my channel.

Your support on my channel is highly appreciated.

Thank you very much.








Program Listing


loginusers.sql


-- phpMyAdmin SQL Dump

-- version 4.0.4.1

-- http://www.phpmyadmin.net

--

-- Host: 127.0.0.1

-- Generation Time: Feb 08, 2021 at 07:09 AM

-- Server version: 5.6.11

-- PHP Version: 5.5.1


SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";

SET time_zone = "+00:00";



/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;

/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;

/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;

/*!40101 SET NAMES utf8 */;


--

-- Database: `login`

--


-- --------------------------------------------------------


--

-- Table structure for table `loginusers`

--


CREATE TABLE IF NOT EXISTS `loginusers` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `username` varchar(100) NOT NULL,

  `password` varchar(100) NOT NULL,

  PRIMARY KEY (`id`)

) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;


--

-- Dumping data for table `loginusers`

--


INSERT INTO `loginusers` (`id`, `username`, `password`) VALUES

(1, '123', '123'),

(2, 'admin', 'admin'),

(3, 'jake', 'jake'),

(4, 'iya', 'iya'),

(5, 'allie', 'allie'),

(6, 'jacob', 'jacob');


/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;

/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;

/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;



Imports MySql.Data.MySqlClient

Public Class Form1
    Dim connection As New MySqlConnection("datasource=localhost;port=3306;username=root;password=;database=login")

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Me.Close()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim command As New MySqlCommand("SELECT username,password FROM loginusers WHERE username = @username AND password = @password", connection)

        command.Parameters.Add("@username", MySqlDbType.VarChar).Value = TextBox1.Text
        command.Parameters.Add("@password", MySqlDbType.VarChar).Value = TextBox2.Text


        Dim adapter As New MySqlDataAdapter(command)
        Dim table As New DataTable()

        adapter.Fill(table)

        If table.Rows.Count = 0 Then

            MessageBox.Show("Invalid Username Or Password. Try Again")
            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox1.Focus()

        Else

            MessageBox.Show("Login Successfully")


            Form2.Show()
            Me.Hide()

        End If

    End Sub
End Class


No comments:

Post a Comment