silahkan dicoba :
Imports System.Data.SqlClient
Public Class Form1
Dim con As SqlConnection
Dim sql As String
Dim da As New SqlDataAdapter
Dim dr As SqlDataReader
Dim cmd As New SqlCommand
Dim ds As DataSet
Sub koneksi()
sql = "Data Source=ADI\SQLEXPRESS;integrated security= true;initial catalog=kursus"
con = New SqlConnection(sql)
If con.State = ConnectionState.Closed Then
con.Open()
Else
con.Close()
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'con.ConnectionString = "Data Source=ADI\SQLEXPRESS;integrated security= true;initial catalog=kursus"
'con.Open()
koneksi()
da = New SqlDataAdapter("Select * from kode", con)
ds = New DataSet
ds.Clear()
da.Fill(ds, "namakursus")
DGV.DataSource = ds.Tables("namakursus")
End Sub
Private Sub txtkdpaket_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtkdpaket.TextChanged
cmd.Connection = con
cmd.CommandText = "Select * from kode where kode = '" & txtkdpaket.Text & "'"
dr = cmd.ExecuteReader
dr.Read()
If dr.HasRows = True Then
txtnmpaket.Text = dr.Item(1)
Else : txtnmpaket.Text = ""
End If
cmd.Dispose()
dr.Close()
da = New SqlDataAdapter("Select * from kode where kode like '" & txtkdpaket.Text & "%'", con)
ds = New DataSet
ds.Clear()
da.Fill(ds, "namakursus")
DGV.DataSource = ds.Tables("namakursus")
End Sub
End Class
Read More
Imports System.Data.SqlClient
Public Class Form1
Dim con As SqlConnection
Dim sql As String
Dim da As New SqlDataAdapter
Dim dr As SqlDataReader
Dim cmd As New SqlCommand
Dim ds As DataSet
Sub koneksi()
sql = "Data Source=ADI\SQLEXPRESS;integrated security= true;initial catalog=kursus"
con = New SqlConnection(sql)
If con.State = ConnectionState.Closed Then
con.Open()
Else
con.Close()
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'con.ConnectionString = "Data Source=ADI\SQLEXPRESS;integrated security= true;initial catalog=kursus"
'con.Open()
koneksi()
da = New SqlDataAdapter("Select * from kode", con)
ds = New DataSet
ds.Clear()
da.Fill(ds, "namakursus")
DGV.DataSource = ds.Tables("namakursus")
End Sub
Private Sub txtkdpaket_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtkdpaket.TextChanged
cmd.Connection = con
cmd.CommandText = "Select * from kode where kode = '" & txtkdpaket.Text & "'"
dr = cmd.ExecuteReader
dr.Read()
If dr.HasRows = True Then
txtnmpaket.Text = dr.Item(1)
Else : txtnmpaket.Text = ""
End If
cmd.Dispose()
dr.Close()
da = New SqlDataAdapter("Select * from kode where kode like '" & txtkdpaket.Text & "%'", con)
ds = New DataSet
ds.Clear()
da.Fill(ds, "namakursus")
DGV.DataSource = ds.Tables("namakursus")
End Sub
End Class