Thursday, February 4, 2021

Display Records Using Date Picker in VB.NET and MySQL

 In this tutorial I will share with you how to display records from database using Date Picker of 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


' Mr. Jake Rodriguez Pomperada, MAED-IT, MIT
' www.jakerpomperada.com and jakerpomperada.blogspot.com
' jakerpomperada@gmail.com
' Bacolod City,Negros Occidental Philippines
' Tools :  Microsoft Visual Studio 2015 Professional Edition
'          MySQL for Visual Studio Version 1.2.9

Imports MySql.Data.MySqlClient
Public Class Form1

    Dim connection As New MySqlConnection("datasource=localhost;port=3306;username=root;password=;database=users")

    Private Sub Search_Data_In_MySQL_Between_2_Date_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Dim table As New DataTable()
        Dim adapter As New MySqlDataAdapter("SELECT * FROM personnel", connection)

        adapter.Fill(table)

        DataGridView1.DataSource = table

    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim table As New DataTable()
        Dim command As New MySqlCommand("SELECT * FROM personnel WHERE dob BETWEEN @d1 AND @d2", connection)

        command.Parameters.Add("@d1", MySqlDbType.Date).Value = DateTimePicker1.Value
        command.Parameters.Add("@d2", MySqlDbType.Date).Value = DateTimePicker2.Value

        Dim adapter As New MySqlDataAdapter(command)

        adapter.Fill(table)

        DataGridView1.DataSource = table

    End Sub


End Class


users.sql

-- phpMyAdmin SQL Dump
-- version 4.0.4.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Feb 04, 2021 at 05:31 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: `users`
--
CREATE DATABASE IF NOT EXISTS `users` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `users`;

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

--
-- Table structure for table `personnel`
--

CREATE TABLE IF NOT EXISTS `personnel` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(200) NOT NULL,
  `email` varchar(200) NOT NULL,
  `dob` date NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;

--
-- Dumping data for table `personnel`
--

INSERT INTO `personnel` (`id`, `name`, `email`, `dob`) VALUES
(1, 'Jake', 'jakerpomperada@gmail.com', '2021-02-01'),
(2, 'Jacob', 'jacob@gmail.com', '2021-02-02'),
(3, 'Julianna', 'julianna@gmail.com', '2021-02-03'),
(4, 'Ma. Junallie', 'allie@yahoo.com.ph', '2021-02-04'),
(5, 'Lydia', 'lydia@gmail.com', '2021-02-06'),
(6, 'virgilio', 'vir@hotmail.com', '2021-02-07'),
(7, 'Jun', 'jun@gmail.com', '2021-03-01'),
(8, 'Sally', 'sally@yahoo.com', '2021-02-14'),
(9, 'James', 'james@gmail.xcom', '2021-04-15'),
(10, 'Mario', 'mario@yahoo.com', '2021-03-23');

/*!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 */;




No comments:

Post a Comment