11-03-16, 06:31 AM
السلام عليكم
ارجو المساعدة في حل مشكلة عدم تغير الصورة اثناء تعديل البيانات
علما اني استخدم قاعدة بيانات access مع vb.net
وهذا هو الكود
conn.Open()
PictureBox7.Refresh()
Dim arrImage() As Byte
Dim strImage As String
Dim myMs As New IO.MemoryStream
If Not IsNothing(Me.PictureBox7.Image) Then
Me.PictureBox7.Image.Save(myMs, Me.PictureBox7.Image.RawFormat)
arrImage = myMs.GetBuffer
strImage = "?"
Else
arrImage = Nothing
strImage = "NULL"
End If
Try
Dim cmdupdate As New OleDbCommand
cmdupdate.Connection = conn
cmdupdate.CommandText = "UPDATE tb SET id_name = '" & Me.txtid.Text & "',photo='" & strImage & "' WHERE name_n = '" + txtname.Text + "'"
If strImage = "?" Then
cmdupdate.Parameters.Add(strImage, OleDb.OleDbType.Binary).Value = arrImage
End If
For Each ar As Byte In arrImage
myMs.WriteByte(ar)
Next
Me.PictureBox7.Image = System.Drawing.Image.FromStream(myMs)
MsgBox("!تم تعديل البيانات بنجاح")
cmdupdate.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
conn.Close()
ارجو المساعدة في حل مشكلة عدم تغير الصورة اثناء تعديل البيانات
علما اني استخدم قاعدة بيانات access مع vb.net
وهذا هو الكود
conn.Open()
PictureBox7.Refresh()
Dim arrImage() As Byte
Dim strImage As String
Dim myMs As New IO.MemoryStream
If Not IsNothing(Me.PictureBox7.Image) Then
Me.PictureBox7.Image.Save(myMs, Me.PictureBox7.Image.RawFormat)
arrImage = myMs.GetBuffer
strImage = "?"
Else
arrImage = Nothing
strImage = "NULL"
End If
Try
Dim cmdupdate As New OleDbCommand
cmdupdate.Connection = conn
cmdupdate.CommandText = "UPDATE tb SET id_name = '" & Me.txtid.Text & "',photo='" & strImage & "' WHERE name_n = '" + txtname.Text + "'"
If strImage = "?" Then
cmdupdate.Parameters.Add(strImage, OleDb.OleDbType.Binary).Value = arrImage
End If
For Each ar As Byte In arrImage
myMs.WriteByte(ar)
Next
Me.PictureBox7.Image = System.Drawing.Image.FromStream(myMs)
MsgBox("!تم تعديل البيانات بنجاح")
cmdupdate.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
conn.Close()