Please following below :
Create Database and Tabel
Create Database : DB_MYPP
Create Table : TBL_PRODUCT
Add sample data in TBL_PRODUCT
2. Design Form and Place a Code
Place code below at Form1
Imports System.Data.SqlClient
Public Class Form1
Dim Conn As SqlConnection
Dim da As SqlDataAdapter
Dim ds As DataSet
Dim CMD As SqlCommand
Dim RD As SqlDataReader
Dim DBLocation As String
Sub 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 Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
OpenDB()
da = New SqlDataAdapter("Select * from TBL_PRODUCT", Conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "TBL_PRODUCT")
DataGridView1.DataSource = (ds.Tables("TBL_PRODUCT"))
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
Call OpenDB()
CMD = New SqlCommand("select * from TBL_PRODUCT where PRODUCT_NAME like '%" & TextBox1.Text & "%'", Conn)
RD = CMD.ExecuteReader
RD.Read()
If RD.HasRows Then
Call OpenDB()
da = New SqlDataAdapter("select * from TBL_PRODUCT where PRODUCT_NAME like '%" & TextBox1.Text & "%'", Conn)
ds = New DataSet
da.Fill(ds, "GetDataProduct")
DataGridView1.DataSource = ds.Tables("GetDataProduct")
DataGridView1.ReadOnly = True
End If
End Sub
End Class
You can start or run your Project, Thanks for visiting BelajarVB and dont forget to comment below
Next Article
« Prev Post
« Prev Post
Previous Article
Next Post »
Next Post »
Penulisan markup di komentar
- Untuk menulis huruf bold silahkan gunakan
<strong></strong>
atau<b></b>
. - Untuk menulis huruf italic silahkan gunakan
<em></em>
atau<i></i>
. - Untuk menulis huruf underline silahkan gunakan
<u></u>
. - Untuk menulis huruf strikethrought silahkan gunakan
<strike></strike>
. - Untuk menulis kode HTML silahkan gunakan
<code></code>
atau<pre></pre>
atau<pre><code></code></pre>
, dan silahkan parse dulu kodenya pada kotak parser di bawah ini.
Konversi Code
Silahkan Berkomentar Dengan