- Step 1: Create New Project use VB 2013
- Step 2 :Create database and table in MS Access 2003
- Step 3 : Design form in VB .Net 2013
Step : 1
Click Visual Studio 2013
Click FILE - New - Project..
after that like below picture :
Click OK
After that, please follow STEP 2
Step 2 :
Create Database and Table in SQL Server
Please create database with name : DB_MYAPP
Create Table with name : TBL_PRODUCT
Fill data for sample in TBL_PRODUCT
#Step 3 :
Design form1 like below picture
Design form1 like below picture
Just add "Datagridview1" in Form1
Place below code at Form1
Place below code at Form1
Imports System.Data.SqlClientPublic Class Form1Dim Conn As SqlConnectionDim da As SqlDataAdapterDim ds As DataSetDim DBLocation As StringSub OpenDB()DBLocation = "data source=COMPUTERNAME;initial catalog=DB_MYAPP;integrated security =true"Conn = New SqlConnection(DBLocation)If Conn.State = ConnectionState.Closed Then Conn.Open()End SubPrivate Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.LoadOpenDB()da = New SqlDataAdapter("Select * from TBL_PRODUCT", Conn)ds = New DataSetds.Clear()da.Fill(ds, "TBL_PRODUCT")DataGridView1.DataSource = (ds.Tables("TBL_PRODUCT"))End SubEnd Class
Here for the result :
Is it easy??? Thank you for visiting Blog BelajarVB and Stay tuned for our next lesson :)