01.
Private
Sub
ButtonInsert_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
ButtonInsert.Click
02.
Dim
cnn
As
New
System.Data.OleDb.OleDbConnection
03.
cnn.ConnectionString =
"Provider = Microsoft.Jet.OLEDB.4.0;data source = C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\WindowsApplication1\WindowsApplication1\product.mdb;"
04.
05.
06.
Dim
cmd
As
New
System.Data.OleDb.OleDbCommand
07.
cmd.Connection = cnn
08.
09.
cmd.CommandText =
"insert into product(ProductID,CategoriesID,ProductName,Brand,Model,Color,Price,Quantity) values ("
& txtProductID.Text &
","
& txtTypeID.Text &
","
& txtProductName.Text &
","
& ComboBoxBrand.Text &
","
& txtProductModel.Text &
","
& ComboBoxColor.Text &
","
& txtPrice.Text &
","
& txtQuantity.Text &
")"
10.
11.
cnn.Close()
12.
13.
MessageBox.Show(
"บันทึกข้อมูลเรียบร้อยแล้ว"
)
14.
End
Sub