Private Sub ButtonSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSave.Click
If IsDataComplete() = False Then
Exit Sub
End If
sql = "INSERT INTO Jewelry "
If Not (PictureBox11.Image Is Nothing) Then
sql &= "(Jew_ID,TypeJew_ID,Picture)" &
"VALUES(@jew,@type,@pic)"
Else
sql &= "(Jew_ID,TypeJew_ID)" &
"VALUES(@jew,@type)"
End If
command.Parameters.Clear()
command.CommandText = sql
command.Parameters.AddWithValue("@jew", ComboBox11.Items.ToString())
command.Parameters.AddWithValue("@type", ComboBox21.Items.ToString())
If Not (PictureBox11.Image Is Nothing) Then
Dim pic() As Byte = ReadImage()
command.Parameters.AddWithValue("pic", pic)
End If
Dim result As Integer = command.ExecuteNonQuery()
If result = -1 Then
MessageBox.Show("เกิดข้อผิดพลาดไม่สามารถเพิ่มข้อมูลได้")
Else
MessageBox.Show("บันทึกข้อมูลแล้ว")
ButtonAdd.PerformClick()
End If
End Sub
'ต้องการจะบันทึกข้อมูลที่อยู่ใน Combobox แต่ติด Object reference not set to an instance of an object. คับ แก้ไขยังไงช่วยทีคับ