27-10-24, 03:18 PM
سبحان الله
طيب جرب هذا الكود
طيب جرب هذا الكود
كود :
Public Sub Update_Car_Arshef(ByVal Car_Doc As PictureBox, ByVal IDW As Long)
Try
Dim folderPath As String = Path.Combine(Application.StartupPath, "Images")
If Not Directory.Exists(folderPath) Then
Directory.CreateDirectory(folderPath)
End If
Dim imagePath As String = Path.Combine(folderPath, IDW.ToString() & ".jpg")
If File.Exists(imagePath) Then
File.Delete(imagePath)
End If
Dim bmpCopy As New Bitmap(Car_Doc.Image)
bmpCopy.Save(imagePath, System.Drawing.Imaging.ImageFormat.Jpeg)
bmpCopy.Dispose()
Dim Cmd As New OleDbCommand
With Cmd
.Connection = con
.CommandType = CommandType.Text
.CommandText = "Update Car_Arshef Set Car_Doc = @Car_Doc Where ID = @ID"
.Parameters.Clear()
.Parameters.AddWithValue("@Car_Doc", imagePath)
.Parameters.AddWithValue("@ID", IDW)
End With
If con.State = ConnectionState.Open Then con.Close()
con.Open()
Cmd.ExecuteNonQuery()
con.Close()
MsgBox("تم تعديل الصورة بنجاح", MsgBoxStyle.Information, "تعديل")
Catch ex As Exception
MsgBox("حدث خطأ أثناء محاولة تعديل الصورة" & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub

