Showing posts with label VB 2008 English Version. Show all posts
Showing posts with label VB 2008 English Version. Show all posts

Simple Insert, Edit, Delete VB .Net 2008 DB MySQL

12:10:00 AM 0
Simple Insert, Edit, Delete VB .Net 2008 DB MySQL
In this tutorial we will share about Simple Add, Edit, Delete VB .Net 2008 Database MySQL. Please make sure you already install MySQL (we use xampp) and Mysql connector.


Please following below steps :


#1
Create database name = mydb
Create table name = TBL_CUSTOMER
Fill sample data in TBL_CUSTOMER like below picture :

#2
Open your VB 2008 Application
Design Form1 like below picture :
Fill below code at Form1
Imports System.Data.Odbc
Public Class Form1
    Dim CONN As OdbcConnection
    Dim CMD As OdbcCommand
    Dim DS As New DataSet
    Dim DA As OdbcDataAdapter
    Dim RD As OdbcDataReader
    Dim DBLocation As String
    Sub DBConn()
        DBLocation = "Driver={MySQL ODBC 3.51 Driver};database=mydb;server=localhost;uid=root"
        CONN = New OdbcConnection(DBLocation)
        If CONN.State = ConnectionState.Closed Then
            CONN.Open()
        End If
    End Sub
    Sub EmptyForm()
        TextBox1.Clear()
        TextBox2.Clear()
        TextBox3.Clear()
        TextBox4.Clear()
        TextBox1.Focus()
    End Sub

    Sub ShowGrid()
        DA = New OdbcDataAdapter("select * from TBL_CUSTOMER", CONN)
        DS = New DataSet
        DA.Fill(DS, "TBL_CUSTOMER")
        DataGridView1.DataSource = DS.Tables("TBL_CUSTOMER")
        DataGridView1.ReadOnly = True
    End Sub

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If TextBox1.Text.Length < 6 Or TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Then
            MsgBox("Data incompleted, Make sure all form is filled and customer id 6 digits")
            Exit Sub
        Else
            Call DBConn()
            CMD = New OdbcCommand("Select * from TBL_CUSTOMER where Customer_id='" & TextBox1.Text & "'", CONN)
            RD = CMD.ExecuteReader
            RD.Read()
            If Not RD.HasRows Then
                Dim simpan As String = "insert into TBL_CUSTOMER values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "')"
                CMD = New OdbcCommand(simpan, CONN)
                CMD.ExecuteNonQuery()
                MsgBox("Add data successed", MsgBoxStyle.Information, "Information www.belajarvb.com")
            Else
                Dim edit As String = "update TBL_CUSTOMER set Name='" & TextBox2.Text & "',Address='" & TextBox3.Text & "',Phone='" & TextBox4.Text & "' where kodeAnggota='" & TextBox1.Text & "'"
                CMD = New OdbcCommand(edit, CONN)
                CMD.ExecuteNonQuery()
                MsgBox("Edit data successed", MsgBoxStyle.Information, "Information")
            End If
            Call ShowGrid()
            Call EmptyForm()
        End If
    End Sub

    Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        If TextBox1.Text = "" Then
            MsgBox("Customer id is empty, please filled it")
            TextBox1.Focus()
            Exit Sub
        Else
            If MessageBox.Show("Are you sure want to delete..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
                Dim hapus As String = "delete * from TBL_CUSTOMER where Customer_id='" & TextBox1.Text & "'"
                CMD = New OdbcCommand(hapus, CONN)
                CMD.ExecuteNonQuery()
                Call ShowGrid()
                Call EmptyForm()
                MsgBox("Deleted successed", MsgBoxStyle.Information, "Information")
            Else
                Call EmptyForm()
            End If
        End If
    End Sub

    Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Call EmptyForm()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Me.Close()
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call DBConn()
        Call ShowGrid()
        Call EmptyForm()
    End Sub

    Private Sub TextBox1_KeyPress1(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        TextBox1.MaxLength = 6
        If e.KeyChar = Chr(13) Then
            Call DBConn()
            CMD = New OdbcCommand("Select * from TBL_CUSTOMER where Customer_id='" & TextBox1.Text & "'", CONN)
            RD = CMD.ExecuteReader
            RD.Read()
            If Not RD.HasRows Then
                TextBox2.Text = ""
                TextBox3.Text = ""
                TextBox4.Text = ""
                TextBox2.Focus()
            Else
                TextBox2.Text = RD.Item("Name")
                TextBox3.Text = RD.Item("Address")
                TextBox4.Text = RD.Item("Phone")
                TextBox2.Focus()
            End If
        End If
    End Sub

    Private Sub TextBox2_KeyPress1(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
        TextBox2.MaxLength = 50
        If e.KeyChar = Chr(13) Then TextBox3.Focus()
    End Sub

    Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
        TextBox3.MaxLength = 50
        If e.KeyChar = Chr(13) Then TextBox4.Focus()
    End Sub
    Private Sub TextBox4_KeyPress1(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress
        TextBox4.MaxLength = 15
        If e.KeyChar = Chr(13) Then Button1.Focus()
    End Sub
End Class
Run your project and You can click here to download Project above / source code

VB .Net 2008 - DB MySQL Connection

12:04:00 AM 0
In this tutorial we will share about VB .Net 2008 - MySQL Connection.
Before following this tutorial, please make sure you already have
Xampp application and install odbc (MySQL ODBC 3.51) in your computer.



Please following below steps :

#1
Create Database in MySQL (Xampp) with name of database = mydb
Create table = TBL_PRODUCT
Fill sample data in TBL_PRODUCT

#2
Open your VB 2008 Application
Design form1 like below picture :
VB .Net 2008 - DB MySQL Connection
Just add "Datagridview1" in Form1

Fill below code at Form1
Imports System.Data.Odbc
Public Class Form1
    Dim Conn As OdbcConnection
    Dim da As OdbcDataAdapter
    Dim ds As DataSet
    Dim str As String
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) _
       Handles MyBase.Load
        Me.Text = "www.belajarvb.com"
        Koneksi()
        da = New OdbcDataAdapter("Select * from TBL_PRODUCT", Conn)
        ds = New DataSet
        ds.Clear()
        da.Fill(ds, "TBL_PRODUCT")
        DataGridView1.DataSource = (ds.Tables("TBL_PRODUCT"))
    End Sub
    Sub Koneksi()
        str = "Driver={MySQL ODBC 3.51 Driver};database=mydb;server=localhost;uid=root"
        Conn = New OdbcConnection(Str)
        If Conn.State = ConnectionState.Closed Then
            Conn.Open()
        End If
    End Sub
End Class

Please run your project
You can click here to download project / source code above

Simple Add, Edit, Delete VB 2008 DB Access 2007 (accdb)

8:06:00 PM 0
Free Soure Code Add, Edit, Delete VB 2008 DB Access 2007 (accdb)
Before built application with Visual Basic 2008, you must know How to Add, Edit Delete in database. in here we will give you lesson VB 2008 How to Add, Edit Delete in Database Access 2007. in this tutorial can also use Microsoft access 2010 or Microsoft access 2013. Because DB Access 2010 and 2013 have same extension (accdb)


Please follow below Lesson :


1. Make sure you already installed Visual Studio 2008 in your computer
2. You already also have installed Microsoft Office 2007 (accdb)

Click Here to Lesson VB 2008 use Access 2003

At first please make database DB.accdb with table Customer and then you can open Visual Basic 2008 and Design form with below picture



and this moment, I will share Free Source code just for you
Please click here to download source code

Simple Add, Edit, Delete VB 2008 DB Access 2003 (mdb)

7:38:00 PM 0
Free Soure Code Simple Add, Edit, Delte VB 2008 DB Access 2003 (mdb)
Before built application with Visual Basic 2008, you must know How to Add, Edit Delete in database. in here we will give you lesson VB 2008 How to Add, Edit Delete in Database Access 2003.

1. Make sure you already installed Visual Studio 2008 in your computer
2. You already also have installed Microsoft Office 2003 (mdb)

Click here to lesson DB Access 2007

At first please make database DB.mdb with table Customer and then you can open Visual Basic 2008 and Design form with below picture
and this moment, I will share Free Source code just for you
Please click here to download source code

Visual Studio 2008 Tutorial

6:23:00 PM 0
Welcome to Belajar VB .com and thanks for visiting this Blog. in this blog you can Learn Visual Basic 6.0, VB 2005, VB 2008, VB 2010 and VB 2013.
in this page just focus to Step by step learn Visual Basic 2008. Please follow below lesson

DATABASE CONNECTION VB .NET 2008

Number Description Click to View
1 VB 2008 - DB Access 2003 Connection View
2 VB 2008 - DB Access 2007 Connection View
3 VB 2008 - DB MySQL Connection View
4 VB 2008 - DB SQL Server Connection View

SIMPLE ADD, EDIT & DELETE VB.NET 2008

Number Description Click to View
1 VB 2008 - Simple Add, Edit & Delete DB Access 2003 View
2 VB 2008 - Simple Add, Edit & Delete DB Access 2007 View
3 VB 2008 - Simple Add, Edit & Delete DB MySQL View
4 VB 2008 - Simple Add, Edit & Delete DB SQL Server View