01.
Imports
System.Data.OleDb
02.
Imports
System.Data
03.
04.
Public
Class
Form3
05.
Dim
cmd
As
OleDbConnection
06.
Dim
Ds
As
DataSet
07.
Dim
Da
As
OleDbDataAdapter
08.
09.
10.
Private
Sub
Form3_Load(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
MyBase
.Load
11.
Try
12.
cmd =
New
OleDbConnection(
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\CRU_003\Documents\Visual Studio 2008\Projects\MyProject\ข้อมูลนักศึกษา.accdb"
)
13.
cmd.Open()
14.
MsgBox(
"Connection"
)
15.
Call
DataShow()
16.
Catch
ex
As
Exception
17.
MsgBox(
"No connection"
)
18.
End
Try
19.
20.
21.
22.
End
Sub
23.
24.
Sub
DataShow()
25.
Ds =
New
DataSet
26.
Da =
New
OleDbDataAdapter(
"SELECT * FROM Student"
, cmd)
27.
Da.Fill(Ds,
"Student"
)
28.
DataGridView1.DataSource = Ds.Tables(
"Student"
)
29.
30.
End
Sub
31.
32.
Private
Sub
ButAdd_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
ButAdd.Click
33.
Ds =
New
DataSet
34.
Da =
New
OleDbDataAdapter(
"INSERT INTO Student (ลำดับ,รหัสแท็ก,ชื่อ,รหัสนักศึกษา,คณะ/สำนัก,สาขาวิชา) VALUES ('"
& TextID.Text.Trim.ToUpper &
"','"
& TextTAGID.Text.Trim.ToUpper &
"','"
& TextNane.Text.Trim.ToUpper &
"','"
& TextSTDID.Text.Trim.ToUpper &
"','"
& Textคณะ.Text.Trim.ToUpper &
"','"
& Textวิชา.Text.Trim.ToUpper &
"')"
, cmd)
35.
Da.Fill(Ds,
"Student"
)
36.
Call
DataShow()
37.
TextID.Clear()
38.
TextTAGID.Clear()
39.
TextNane.Clear()
40.
TextSTDID.Clear()
41.
Textคณะ.Clear()
42.
Textวิชา.Clear()
43.
End
Sub
44.
End
Class