01.
Imports
System.Data
02.
Imports
System.Data.SqlClient
03.
Public
Class
Form1
04.
Friend
cn
As
New
SqlConnection(
"Server=DESKTOP-E8VU2LH\SQL;Database=TU1;User Id=sa; Password=1234;"
)
05.
Friend
cmd
As
New
SqlCommand
06.
Friend
da
As
New
SqlDataAdapter
07.
Friend
ds
As
New
DataSet
08.
Friend
dr
As
SqlDataReader
09.
Friend
dt
As
New
DataTable
10.
Friend
sql
As
String
11.
Public
Sub
open_database()
12.
If
cn.State = ConnectionState.Closed
Then
cn.Open()
13.
14.
End
Sub
15.
Private
Sub
Form1_Load(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
MyBase
.Load
16.
load_product()
17.
sql =
"select ชื่อ from name"
18.
cmd_database(ComboBox1)
19.
load_labal()
20.
load_auto()
21.
Try
22.
Dim
con
As
New
OleDbConnection
23.
con.ConnectionString = (
"Server=DESKTOP-E8VU2LH\SQL;Database=TU1;User Id=sa; Password=1234;"
)
24.
con.Open()
25.
26.
con.Open()
27.
Dim
daauto
As
New
SqlDataAdapter(
"select ชื่อ from name"
, cn)
28.
ds.Tables.Add(dt)
29.
daauto.Fill(dt)
30.
31.
Dim
r
As
DataRow
32.
TextBox2.AutoCompleteCustomSource.Clear()
33.
34.
For
Each
r
In
dt.Rows
35.
TextBox2.AutoCompleteCustomSource.Add(r.Item(0).ToString)
36.
37.
Next
38.
cn.Close()
39.
Catch
ex
As
Exception
40.
41.
42.
End
Try
43.
End
Sub
44.
45.
46.
47.
End
Class