07-08-19, 02:22 AM
(آخر تعديل لهذه المشاركة : 07-08-19, 02:23 AM {2} بواسطة Saad Alward.)
ضع نوع الحقل الى Image
هذا كود لعملية الادخال او التحديث اذا كانت الصوره في PictureBox
وهذا الكود لتحويل الصوره من image الى Byte
وهذا الكود لتحويل من bytearray الى image
هذا كود لعملية الادخال او التحديث اذا كانت الصوره في PictureBox
كود :
Dim CMD As SqlCommand
CMD = New SqlCommand("update T_NAMES set c_names_image=@c_names_image where c_names_id='" & NAMES_id_code.Trim & "'", SQLCLIENTCN)
CMD.Parameters.Add(New SqlClient.SqlParameter("@c_names_image", SqlDbType.Image)).Value = imgToByteConverter(PictureBox1.Image)
CMD.ExecuteNonQuery()
CMD.Dispose()وهذا الكود لتحويل الصوره من image الى Byte
كود :
'convert image to bytearray
Public Function imgToByteConverter(ByVal inImg As Image) As Byte()
Dim imgCon As New ImageConverter()
Return DirectCast(imgCon.ConvertTo(inImg, GetType(Byte())), Byte())
End Functionوهذا الكود لتحويل من bytearray الى image
كود :
'convert bytearray to image
Public Function byteArrayToImage(ByVal byteArrayIn As Byte()) As Image
Using mStream As New MemoryStream(byteArrayIn)
Return New Bitmap(Image.FromStream(mStream))
End Using
End Function