Private Sub SaveDataImage Dim sqlSaveImage As String = "INSERT INTO tblpasien VALUES(@no,@nama,@alamat,@usia,@kelamin,@gambar)" Try Dim OdbCommand As OleDbCommand = New OleDbCommand(sqlSaveImage,Koneksi) If isTextEmpty(Me) = False Then '<-- This is my own sub procedure With OdbCommand.Parameters .AddWithValue("@no",txtNoPasien.Text) .AddWithValue("@nama",txtNama.Text) .AddWithValue("@alamat",txtAlamat.Text) .AddWithValue("@usia",txtUsia.Text) .AddWithValue("@kelamin", cmbKelamin.Text) End With Dim StreamImage As New MemoryStream() PictureBox1.Image.Save(StreamImage, PictureBox1.Image.RawFormat) Dim BufferImage As byte() = StreamImage.GetBuffer OdbCommand.Parameters.AddWithValue("@gambar", SqlDbType.Image).Value = BufferImage 'Execution Koneksi.Open OdbCommand.ExecuteNonQuery Koneksi.Close 'Clear text ClearAllText(Me) txtNoPasien.Focus 'Show in grid after saving mdlConnection.ShowPatientsGrid(DGPatients) GridPlan 'pict variable must be empty after execution pict = String.Empty Me.PictureBox1.Image = My.Resources.Label Else MsgBox("Entri data kosong",vbInformation) pict = String.Empty Exit Sub End if Catch ex As Exception Koneksi.Close MsgBox("Tidak bisa menyimpan data. Terdapat kesalahan penulisan",vbExclamation) End Try End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)