Private Sub Btnupdate_Click() Handles Btnupdate.Click
If TextID.Text = "" Or IsDataComplete() = False Then
Exit Sub
End If
Dim s As String
If Not (PictureBox1.Image Is Nothing) Then
s = ",Picture=@pic"
Else
s = ""
End If
sql = "UPDATE Employee SET" &
"Emp_ID=@id,Emp_Name= @name,Emp_Las = @last,Emp_Age = @age,Emp_Num = @num,Emp_Add = @add" & s
command.Parameters.Clear()
command.CommandText = sql
command.Parameters.AddWithValue("@id", TextID.Text)
command.Parameters.AddWithValue("@name", Textname.Text)
command.Parameters.AddWithValue("@last", Textlats.Text)
command.Parameters.AddWithValue("@age", Textage.Text)
command.Parameters.AddWithValue("@num", Textnum.Text)
command.Parameters.AddWithValue("@add", Textadd.Text)
If Not (PictureBox1.Image Is Nothing) Then
Dim byteArr() As Byte = ReadImage()
command.Parameters.AddWithValue("pic", byteArr)
End If
If command.ExecuteNonQuery() = 1 Then
MessageBox.Show("บันทึกการเปลี่ยนแปลงแล้ว")
UpdateBinding()
Else
MessageBox.Show("เกิดข้อผิดพลาด")
End If
End Sub
End Class
Private Sub Btnupdate_Click() Handles Btnupdate.Click
If TextID.Text = "" Or IsDataComplete() = False Then
Exit Sub
End If
Dim s As String
If Not (PictureBox1.Image Is Nothing) Then
s = ",Picture=@pic"
Else
s = ""
End If
sql = "UPDATE Employee SET Emp_ID = @id, Emp_Name = @name,Emp_Las = @last,Emp_Age = @age,Emp_Num = @num,Emp_Add = @add" & s
command.Parameters.Clear()
command.CommandText = sql
command.Parameters.AddWithValue("@id", TextID.Text)
command.Parameters.AddWithValue("@name", Textname.Text)
command.Parameters.AddWithValue("@last", Textlats.Text)
command.Parameters.AddWithValue("@age", Textage.Text)
command.Parameters.AddWithValue("@num", Textnum.Text)
command.Parameters.AddWithValue("@add", Textadd.Text)
If Not (PictureBox1.Image Is Nothing) Then
Dim byteArr() As Byte = ReadImage()
command.Parameters.AddWithValue("pic", byteArr)
End If
If command.ExecuteNonQuery() = 1 Then
MessageBox.Show("บันทึกการเปลี่ยนแปลงแล้ว")
UpdateBinding()
Else
MessageBox.Show("เกิดข้อผิดพลาด")
End If
End Sub
End Class