Imports System.Object
Imports System.Exception
Imports System.SystemException
Imports System.Data.SqlClient.SqlException
Imports System.Data.SqlClient
Imports System.Data.SqlServerCe.SqlCeException
Public Class Add
Private Sub Btn_Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Add.Click
If Me.txt_depid.Text = "" Then
MessageBox.Show("Please input (Name)")
Me.txt_depid.Focus()
Exit Sub
End If
If Me.txt_depcode.Text = "" Then
MessageBox.Show("Please input (Email)")
Me.txt_depcode.Focus()
Exit Sub
End If
Dim myConnection As SqlCeConnection
myConnection = New SqlCeConnection("Data Source=C:\Project\ITDatabase.sdf;")
myConnection.Open()
Dim myCommand As SqlCeCommand = myConnection.CreateCommand()
myCommand.CommandText = "INSERT INTO ITDatabase (Dep_Id, Dep_Code) VALUES " & _
" ('" & Me.txt_depid.Text & "','" & Me.txt_depcode.Text & "' ) "
myCommand.CommandType = CommandType.Text
myCommand.ExecuteNonQuery() **ตรงนี้เลยคับ
myConnection.Close()
MessageBox.Show("Save Successfully.")
Me.Hide()
Dim f As New Department
f.Show()
End Sub