Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Con = New SqlConnection
Dim ConStr As String
ConStr = "Server=user-PC\SQLEXPRESS;Initial Catalog=internetcafe;Integrated Security=SSPI"
Con = New SqlConnection(ConStr)
Con.Open()
Dim Cmd As SqlCommand
Dim MySQL As String
MySQL = "insert intro Officer(Name,Surname,Birthday,LoginRight,Username,Password)"
MySQL += "Values('" & TextBox2.Text & "','" & TextBox3.Text & "','"
MySQL += Format(DateTimePicker1.Value, "MM/dd/yyyy") & "'," & CheckBox1.CheckState
MySQL += ",'" & TextBox4.Text & "','" & TextBox5.Text & "')"
Cmd = New SqlCommand(MySQL, Con)
Cmd.ExecuteNonQuery()
MsgBox("บันทึกรายการเรียบร้อย")
End Sub
End Class