Private Sub btnKey1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKey1.Click
Dim sqlADD As String
Dim cm As New OleDbCommand()
Dim objConn As OleDbConnection
Dim dt As New DataTable
Dim strConnString As String
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Student_1.mdb"
objConn = New OleDbConnection(strConnString)
objConn.Open()
sqlADD = "INSERT INTO Borrowing Data(ID_Borrowing)VALUES('" & lblID_Borrowing.Text & "',)"
cm.Parameters.Add("lblID_Borrowing", lblID_Borrowing.Text)
cm = New OleDbCommand(sqlADD, objConn)
cm.ExecuteNonQuery()
MessageBox.Show("คุณได้ทำการยืมกุญแจห้องน้ำเรียบร้อยแล้ว", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
End Class
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim sqlADD As String
Dim cm As New OleDbCommand()
Dim objConn As OleDbConnection
Dim dt As New DataTable
Dim strConnString As String
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Student_1.mdb"
objConn = New OleDbConnection(strConnString)
objConn.Open()
sqlADD = "INSERT INTO StudentData([ID_STD],[UserName],[LastName],[Class],[Sex],[Password],[ID_Borrowing])VALUES('" & txtID_STD.Text & "','" & txtUserName.Text & "','" & txtLastName.Text & "','" & txtClass.Text & "','" & txtSex.Text & "','" & txtPassWord.Text & "','" & txtBorrowing.Text & "')"
cm = New OleDbCommand(sqlADD, objConn)
cm.ExecuteNonQuery()
MessageBox.Show("บันทึกข้อมูลนักศึกษาแล้ว", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
txtID_STD.Clear()
txtUserName.Clear()
txtLastName.Clear()
txtPassWord.Clear()
txtClass.Clear()
txtSex.Clear()
txtPassWord.Clear()
txtBorrowing.Clear()
objConn.Close()