Imports System.Data
Imports System.Data.OleDb
Public Class Form5
Const database_file As String = "HR.mdb"
Dim strConnection As String = "provider=microsoft.Jet.Oledb.4.0;" & _
"Data Source=" & database_file
Dim conn As New OleDbConnection(strConnection)
Dim cmd As New OleDbCommand
Dim da As New OleDbDataAdapter
Dim ds As New DataSet
Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Me.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If TextBox1.Text <> "" And TextBox2.Text <> "" And TextBox3.Text <> "" And TextBox4.Text <> "" And TextBox5.Text <> "" Then
Dim upd As String = "INSERT INTO Staff (ID,Name,Sername,Position,Department)" & _
" VALUES ( '" & TextBox1.Text & "'," & _
"'" & TextBox2.Text & "'," & _
"'" & TextBox3.Text & "'," & _
"'" & TextBox4.Text & "'," & _
"'" & TextBox5.Text & "',"
Dim cm As New OleDbCommand(upd, conn)
conn.Open()
cm.ExecuteNonQuery()
MessageBox.Show("บันทึกข้อมูลเรียบร้อยแล้วคะ", " my", MessageBoxButtons.OK, MessageBoxIcon.Information)
conn.Close()
Else
MsgBox("กรุณากรอกข้อมูลให้ครบค่ะ", MsgBoxStyle.Information, "Information")
End If
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
End Sub
End Class
Tag : .NET, Web (ASP.NET), Win (Windows App), VB.NET, VS 2010 (.NET 4.x)