01.
Imports
System.Data.OleDb
02.
Public
Class
frmadd
03.
Dim
conn
As
New
OleDbConnection
04.
Dim
da
As
OleDbDataAdapter
05.
Dim
ds
As
DataSet
06.
Private
Sub
btnadd_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
btnadd.Click
07.
Dim
strcon
As
String
08.
strcon =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Documents\account.mdb"
09.
With
conn
10.
If
.State = ConnectionState.Open
Then
.Close()
11.
.ConnectionString = strcon
12.
.Open()
13.
End
With
14.
Dim
sqlaccount
As
String
15.
Dim
cmdaccount
As
New
OleDbCommand
16.
sqlaccount =
"INSERT INTO account (no, ac_name, ac_id, range, ac_begin, ac_finish, ac_fund, ac_tax) VALUES (2, 'ทดสอบ2', '6666', 12, '1/1/2010', '1/1/2011', 20000, 6)"
17.
MessageBox.Show(sqlaccount)
18.
Try
19.
With
cmdaccount
20.
.CommandType = CommandType.Text
21.
.CommandText = sqlaccount
22.
.Connection = conn
23.
.ExecuteNonQuery()
24.
End
With
25.
Catch
ex
As
Exception
26.
MessageBox.Show(ex.ToString)
27.
End
Try
28.
End
Sub