Friday, January 18, 2019

Login Security System Using Visual Basic NET and MySQL

A simple program that I wrote that show you how to create login security using Visual Basic NET and MySQL as our database.

I hope you will find my work useful. Thank you.

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 in 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 I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com










Sample Program Output


Program Listing

Imports MySql.Data.MySqlClient

Public Class Form1
    Dim cmd As New MySqlCommand
    Dim da As New MySqlDataAdapter
    Dim con As MySqlConnection = conn()

    Public Function conn() As MySqlConnection
        Return New MySqlConnection("server=localhost;user id=root;password=;database=studentdb")
    End Function
    Private Sub btnlogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlogin.Click
        Dim sql As String
        Dim publictable As New DataTable
        Try
            If txtuname.Text = "" And txtpass.Text = "" Then
                MsgBox("Password or Username Textbox Cannot be Empty.", vbCritical, "Remainder")
                txtuname.Text = ""
                txtpass.Text = ""
                txtuname.Focus()
            Else
                sql = "select * from tbluseraccounts where username ='" & txtuname.Text & "' and userpassword = '" & txtpass.Text & "'"
                With cmd
                    .Connection = con
                    .CommandText = sql
                End With
                da.SelectCommand = cmd
                da.Fill(publictable)
                If publictable.Rows.Count > 0 Then
                    Dim user_type, name As String
                    user_type = publictable.Rows(0).Item(4)
                    name = publictable.Rows(0).Item(2)
                    If user_type = "Admin" Then
                        MsgBox("Welcome " & name & " you login as Administrator ", vbInformation, "Welcome")
                        lbllogin.Text = "Logout"
                        GroupBox1.Enabled = False
                        txtuname.Text = ""
                        txtpass.Text = ""
                        lblname.Font = New Font(lblname.Font, FontStyle.Bold)
                        lblname.Text = "Hi, " & UCase(name)

                    ElseIf user_type = "Encoder" Then
                        MsgBox("Welcome " & name & " you login as Encoder ", vbInformation, "Welcome")
                        lbllogin.Text = "Logout"
                        GroupBox1.Enabled = False
                        txtuname.Text = ""
                        txtpass.Text = ""
                        lblname.Font = New Font(lblname.Font, FontStyle.Bold)
                        lblname.Text = "Hi, " & UCase(name)
                    Else
                        MsgBox("You login as Guest!", vbInformation, "Welcome")
                        lbllogin.Text = "Logout"
                        GroupBox1.Enabled = False
                        txtuname.Text = ""
                        txtpass.Text = ""
                        lblname.Font = New Font(lblname.Font, FontStyle.Bold)
                        lblname.Text = "Hi, " & UCase(name)
                    End If

                Else
                    MessageBox.Show("Username or Password is Incorrect" & vbNewLine _
                       & vbNewLine _
                       & "Kindly try again please." & vbNewLine & vbNewLine _
                       & "Program developed By : Mr. Jake Rodriguez Pomperada" & vbNewLine _
                       , "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
                    txtuname.Text = ""
                    txtpass.Text = ""
                    txtuname.Focus()
                End If

                da.Dispose()
            End If

        Catch ex As Exception
            MsgBox(ex.Message)

        End Try
        con.Clone()

       
    End Sub

    Private Sub lbllogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbllogin.Click

        If lbllogin.Text = "Logout" Then
            lbllogin.Text = "Login"
            lblname.Text = "Hi, Guest!"
        ElseIf lbllogin.Text = "Login" Then
            GroupBox1.Enabled = True

        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        GroupBox1.Enabled = False
        Dim toolTip1 As New ToolTip()
        toolTip1.ShowAlways = True
        toolTip1.SetToolTip(lbllogin, "Click here to login or logout to the system.")

    End Sub
End Class


studentdb.sql

-- phpMyAdmin SQL Dump
-- version 4.8.4
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jan 18, 2019 at 09:11 AM
-- Server version: 10.1.37-MariaDB
-- PHP Version: 7.3.0

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
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 utf8mb4 */;

--
-- Database: `studentdb`
--

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

--
-- Table structure for table `tbluseraccounts`
--

CREATE TABLE `tbluseraccounts` (
  `userID` int(11) NOT NULL,
  `username` varchar(255) DEFAULT NULL,
  `users_name` varchar(255) DEFAULT NULL,
  `userpassword` varchar(255) DEFAULT NULL,
  `usertype` varchar(255) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbluseraccounts`
--

INSERT INTO `tbluseraccounts` (`userID`, `username`, `users_name`, `userpassword`, `usertype`) VALUES
(1, 'admin', 'Jake R. Pomperada', 'admin', 'Admin'),
(2, 'jacob', 'Jacob Samue F. Pomperada', 'jacob', 'guest'),
(3, 'iya', 'Julianna Rae F. Pomperada', 'iya', 'Encoder');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `tbluseraccounts`
--
ALTER TABLE `tbluseraccounts`
  ADD PRIMARY KEY (`userID`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `tbluseraccounts`
--
ALTER TABLE `tbluseraccounts`
  MODIFY `userID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
COMMIT;

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



User Profile System Using Visual Basic NET, MySQL and Crystal Report

I started learning and working again with Visual Basic NET because our application in my workplace is not working it is written in Microsoft Access but after a day I was able to make the application works again by fixing the printer configuration. While I'm learning Visual Basic NET I have decided to create a User Profile System which uses MySQL as it's backend database and Crystal Report for report generation.

Actually, this will be my first time to use MySQL as my backend database and Crystal Report for my report generation. Most of the time when I am writing a Visual Basic NET program my backend is Microsoft Access. I want my program to become scalable by using MySQL as my backend. In terms of reporting Crystal Report is much better compared to the built-in reporting tool in Visual Basic NET. I am having a hard time understanding first it's concepts and all the configuration like MySQL ODBC connector configuration but I was able to connect all of them correctly in my application. Remember Crystal Report is a third party product of SAP, not a Microsoft product which requires proper and correct configuration in order to work properly within your application.

Overall my learning process is a very productive and enjoyable one for me. I learned a lot through trial and error process, use of analytical thinking skills and never give up attitude towards programming.

I hope you will find my work useful. Thank you.

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 in 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 I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com






Screenshots of the Sample Program Output


Program Listing


Form1 Code 

Imports MySql.Data.MySqlClient
'Simple CRUD application in Visual Basic NET and MySQL with Crystal Report
' Written By Mr. Jake R. Pomperada,MAED-IT
' January 19, 2019  Friday
' jakerpomperada@gmail.com and jakerpomperada@aol.com
' http://www.jakerpomperada.com


Public Class Form1
    Dim str As String = "server=localhost; uid=root; pwd=; database=dbprofile"
    Dim con As New MySqlConnection(Str)

    Sub loadme()
        Label6.Text = "Date : " & Date.Today
        Label7.Text = "Time : " & DateTime.Now.ToString("HH:mm:ss tt")
        Dim query As String = "select * from profile"
        Dim adpt As New MySqlDataAdapter(query, con)
        Dim ds As New DataSet()
        adpt.Fill(ds, "users")
        DataGridView1.DataSource = ds.Tables(0)
        con.Close()
        TextBox1.Clear()
        TextBox2.Clear()
        TextBox3.Clear()
        TextBox4.Clear()
        TextBox1.Focus()
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        loadme()
    End Sub

    Private Sub btn_add_Click(sender As Object, e As EventArgs) Handles btn_add.Click
        Dim cmd As MySqlCommand
        con.Open()
        Try
            cmd = con.CreateCommand
            cmd.CommandText = "insert into profile(id,name,mobile,email)values(@id,@name,@mobile,@email);"
            cmd.Parameters.AddWithValue("@id", TextBox1.Text)
            cmd.Parameters.AddWithValue("@name", UCase(TextBox2.Text))
            cmd.Parameters.AddWithValue("@mobile", TextBox3.Text)
            cmd.Parameters.AddWithValue("@email", LCase(TextBox4.Text))
            cmd.ExecuteNonQuery()
            MessageBox.Show("Record has been saved successfully", "Save Record", MessageBoxButtons.OK, MessageBoxIcon.Information)
            loadme()
        Catch ex As Exception

        End Try
    End Sub

    Private Sub DataGridView1_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
        Dim row As DataGridViewRow = DataGridView1.CurrentRow
        Try
            TextBox1.Text = row.Cells(0).Value.ToString()
            TextBox2.Text = row.Cells(1).Value.ToString()
            TextBox3.Text = row.Cells(2).Value.ToString()
            TextBox4.Text = row.Cells(3).Value.ToString()
        Catch ex As Exception

        End Try
    End Sub

    Private Sub btn_update_Click(sender As Object, e As EventArgs) Handles btn_update.Click
        Dim cmd As MySqlCommand
        con.Open()
        Try
            cmd = con.CreateCommand()
            cmd.CommandText = "update profile set name=@name,mobile=@mobile,email=@email where id=@id;"
            cmd.Parameters.AddWithValue("@id", TextBox1.Text)
            cmd.Parameters.AddWithValue("@name", UCase(TextBox2.Text))
            cmd.Parameters.AddWithValue("@mobile", TextBox3.Text)
            cmd.Parameters.AddWithValue("@email", LCase(TextBox4.Text))
            cmd.ExecuteNonQuery()
            MessageBox.Show("Record has been updated successfully", "Update Record", MessageBoxButtons.OK, MessageBoxIcon.Information)
            loadme()
        Catch ex As Exception

        End Try
    End Sub

    Private Sub btn_delete_Click(sender As Object, e As EventArgs) Handles btn_delete.Click
        Dim cmd As MySqlCommand
        con.Open()
        Try
            Select Case MsgBox("Are you sure to delete this record?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Delete Record")
                Case MsgBoxResult.Yes
                    cmd = con.CreateCommand()
                    cmd.CommandText = "delete from profile where id=@id;"
                    cmd.Parameters.AddWithValue("@id", TextBox1.Text)
                    cmd.ExecuteNonQuery()
                    MessageBox.Show("Record has been deleted successfully", "Delete Record", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                    loadme()
                Case MsgBoxResult.No
                    loadme()
            End Select
        Catch ex As Exception

        End Try
    End Sub

    Private Sub btn_reset_Click(sender As Object, e As EventArgs) Handles btn_reset.Click
        loadme()
    End Sub

    Private Sub btn_quit_Click(sender As Object, e As EventArgs) Handles btn_quit.Click
        Select Case MsgBox("Are you sure to quit program?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Quit Program")
            Case MsgBoxResult.Yes
                End
            Case MsgBoxResult.No
                loadme()
        End Select
    End Sub

    Private Sub TextBox5_TextChanged(sender As Object, e As EventArgs) Handles txtsearch.TextChanged
        Dim adapater As MySqlDataAdapter
        Dim ds As New DataSet
        Try
            con.Open()
            adapater = New MySqlDataAdapter("select * from profile where name like '%" & txtsearch.Text & "%'", con)
            adapater.Fill(ds)
            DataGridView1.DataSource = ds.Tables(0)
            con.Close()
            TextBox1.Clear()
            TextBox2.Clear()
            TextBox3.Clear()
            TextBox4.Clear()
        Catch ex As Exception

        End Try
    End Sub


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btn_about.Click
        MessageBox.Show("This Program is Created By Mr. Jake R. Pomperada" & vbNewLine _
                        & vbNewLine _
                        & "Date : January 17, 2019 Thursday" & vbNewLine & vbNewLine _
                        & "Bacolod City, Negros Occidental Philippines" & vbNewLine _
                        & vbNewLine _
                        & "Website : http://www.jakerpomperada.com " & vbNewLine _
                         & vbNewLine _
                        & "Email Address : jakerpomperada@gmail.com" & vbNewLine _
                        , "About This Program", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

    Private Sub btn_print_Click(sender As Object, e As EventArgs) Handles btn_print.Click
        Form2.Show()
    End Sub
End Class


Form2 Code

Imports CrystalDecisions.CrystalReports.Engine
Public Class Form2

  

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim cryRpt As New ReportDocument
        cryRpt.Load("D:\crud_vb_mysql\crud\crud\CrystalReport7.rpt")
        CrystalReportViewer1.ReportSource = cryRpt
        CrystalReportViewer1.Refresh()
    End Sub

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

    End Sub
End Class


dbprofile.sql

/*
SQLyog Ultimate v12.09 (64 bit)
MySQL - 10.1.37-MariaDB : Database - dbprofile
*********************************************************************
*/


/*!40101 SET NAMES utf8 */;

/*!40101 SET SQL_MODE=''*/;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`dbprofile` /*!40100 DEFAULT CHARACTER SET latin1 */;

USE `dbprofile`;

/*Table structure for table `profile` */

DROP TABLE IF EXISTS `profile`;

CREATE TABLE `profile` (
  `id` int(9) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) DEFAULT NULL,
  `mobile` varchar(20) DEFAULT NULL,
  `email` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;

/*Data for the table `profile` */

insert  into `profile`(`id`,`name`,`mobile`,`email`) values (1,'LYDIA POMPERADA','091212121223','lydiapomperada@yahoo.com'),(2,'JAKE POMPERADA','09173084360','jakerpomperada@gmail.com'),(3,'KOBE BRYANT','3434','kobe@lakers.com'),(4,'PETER NORTON','34343','peternorton@gmail.com'),(5,'ROMMEL ADDUCUL','09173949346','rommel@hotmail.com'),(6,'WILLIAM GATES','34434343','gates@taiwan.tw'),(7,'LESLIE PEPITO','12121212','leslie@ford.com');

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;





Thursday, January 17, 2019

Reverse a Number in C

A sample program that will ask the user an integer and then the program will reverse the arrangement of the number.

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 in 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 I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com


Program Listing

#include <stdio.h>
#include <conio.h>

void main()
{
   int NUM, R = 0;
   clrscr();

   printf("Enter a number to reverse\n");
   scanf("%d", &NUM);

   while (NUM != 0)
   {
      R = R * 10;
      R = R + NUM%10;
      NUM= NUM/10;
   }

   printf("After reversing the Number is = %d\n", R);

   getch();
}

Greatest Common Divisor of two integers in C

A simple program Greatest Common Divisor of two integers in C language.

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 in 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 I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com


Program Listing

#include <stdio.h>
#include <conio.h>

void main() {
  int x, y,a,b,t,G;
  clrscr();

  printf("Enter two integers\n");
  scanf("%d %d", &x, &y);

  a = x;
  b = y;

  while (b != 0) {
    t = b;
    b = a % b;
    a = t;
  }
  G = a;
  printf("GCD for %d and %d is ", x, y);
  printf("%d",G);
  getch();
}

Alphabet Checking For Vowels in C

Here is a simple program to ask the user to give a character and then the program will check if the given alphabet is a vowel or not using C language.

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 in 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 I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com


Program Listing


#include <stdio.h>
#include <conio.h>

void main()
{
  char ch;
  clrscr();
  printf("Enter a character ");
  ch=getch();

if(ch==65)
{
printf("%c is Vowel",ch);
}
else
if(ch==69)
{
printf("%c is Vowel",ch);
}
else
if(ch==73)
{
printf("%c is Vowel",ch);
}
else
if(ch==79)
{
printf("%c is Vowel",ch);
}
else
if(ch==85)
{
printf("%c is Vowel",ch);
}
else

printf("The Character %c is not vowel",ch);

getch();

}

Compare Two Strings in C

Here is a simple program to compare two string given by the user in C language.

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 in 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 I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com


Program Listing

include<stdio.h>
#include<conio.h>

void strcmpr(char[],char[]);

void main()

{

    char S1[20],S2[20];
    int COMP;
    clrscr();

    printf("ENTER STRING 1 ");
    scanf("%s",S1);

    printf("ENTER STRING 2 ");
    scanf("%s",S2);

     strcmpr(S1,S2);

getch();

}

void strcmpr(char S1[],char S2[])

{
    int i=0,flag=0;
   
     while(S1[i]!='\0' && S2[i]!='\0')   
  {
         if(S1[i]!=S2[i]){
             flag=1;
             break;
  }
         i++;
    }

    if (flag==0 && S1[i]=='\0' && S2[i]=='\0')
       
  printf("BOTH STRINGS ARE EQUAL");

    else
    printf("BOTH STRINGS ARE NOT EQUAL ");

}