พิมข้อความแล้ว ไห้ขึ้นข้อความตัวเลือก คลายๆกับ google แบบนี้ป่าวครับ พิมใน combobox เชื่ิิอมกับ sql server 2008
Code (VB.NET)
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Friend cn As New SqlConnection("Server=DESKTOP-E8VU2LH\SQL;Database=TU1;User Id=sa; Password=1234;")
Friend cmd As New SqlCommand
Friend da As New SqlDataAdapter
Friend ds As New DataSet
Friend dr As SqlDataReader
Friend dt As New DataTable
Friend sql As String
Public Sub open_database()
If cn.State = ConnectionState.Closed Then cn.Open()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
load_product()
sql = "select ชื่อ from name"
cmd_database(ComboBox1)
load_labal()
load_auto()
Try
Dim con As New OleDbConnection
con.ConnectionString = ("Server=DESKTOP-E8VU2LH\SQL;Database=TU1;User Id=sa; Password=1234;")
con.Open()
con.Open()
Dim daauto As New SqlDataAdapter("select ชื่อ from name", cn)
ds.Tables.Add(dt)
daauto.Fill(dt)
Dim r As DataRow
TextBox2.AutoCompleteCustomSource.Clear()
For Each r In dt.Rows
TextBox2.AutoCompleteCustomSource.Add(r.Item(0).ToString)
Next
cn.Close()
Catch ex As Exception
End Try
End Sub
End Class