Private Sub chdata_beforadd()
If MessageBox.Show("คุณต้องการเพิ่ม ผู้ใช้งาน ใช่หรือไม่?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
Try
sb = New StringBuilder()
sb.Remove(0, sb.Length)
sb.Append("Select * From Username Where (name=@name) And (lastname=@lastname)And (position=@position)And (jobline=@jobline)And (Username=@Username)And (Password=@Password)")
Dim sqlSelect As String = sb.ToString()
com = New SqlCommand(sqlSelect, Conn)
com.Parameters.Clear()
com.Parameters.Add("@name", SqlDbType.NVarChar).Value = Txtname.Text.Trim()
com.Parameters.Add("@lastname", SqlDbType.NVarChar).Value = Txtlast.Text.Trim()
com.Parameters.Add("@position", SqlDbType.NVarChar).Value = Txtposi.Text.Trim()
com.Parameters.Add("@jobline", SqlDbType.NVarChar).Value = Txtjobline.Text.Trim()
com.Parameters.Add("@Username", SqlDbType.NVarChar).Value = Txtuser.Text.Trim()
com.Parameters.Add("@Password", SqlDbType.NVarChar).Value = Txtpass.Text.Trim()
dr = com.ExecuteReader()
If dr.HasRows = True Then
dt = New DataTable()
dt.Load(dr)