|
以下图片存进去了.
Dim filename1 As String
With cdopen
.FileName = ""
.Filter = "请选取文件(*.jpg)|*.jpg"
.ShowDialog()
If Len(.FileName) <> 0 Then
filename1 = (.FileName)
mstream.LoadFromFile(.FileName)
myrs.Fields("文件名").value = .FileName
myrs.Fields("相片").value = mstream.Read
myrs.Update()
Else
MessageBox.Show("没有选择文件!")
Exit Sub
End If
Pi1.Image = New Bitmap(.FileName)
End With
End Sub
FORM装载时显示
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Kill(Application.StartupPath & "\monkey.jpg")
Dim data As Byte() = myrs.Fields("相片").value
Dim myfilestream As New System.IO.FileStream(Application.StartupPath & "\monkey.jpg", IO.FileMode.Create)
myfilestream.Write(data, 0, data.Length)
myfilestream.Close()
Pi1.Image = New Bitmap(Application.StartupPath & "\monkey.jpg")
Kill(Application.StartupPath & "\monkey.jpg")
Catch
End Try
end sub
可是翻页时还是显示Form4_Load时的图片.以下是翻页的代马.
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
If myrs.RecordCount < 1 Then Exit Sub
If Not myrs.EOF Then
myrs.MoveNext()
Else
myrs.MoveLast()
End If
If myrs.EOF Then
myrs.MoveLast()
End If
Me.rs1.Text = (myrs.AbsolutePosition).ToString + "/" + myrs.RecordCount.ToString()
showdata()
Try
Kill(Application.StartupPath & "\monkey.jpg")
Dim data As Byte() = myrs.Fields("相片").value
Dim myfilestream As New System.IO.FileStream(Application.StartupPath & "\monkey.jpg", IO.FileMode.Create)
myfilestream.Write(data, 0, data.Length)
myfilestream.Close()
Pi1.Image = New Bitmap(Application.StartupPath & "\monkey.jpg")
Kill(Application.StartupPath & "\monkey.jpg")
Catch
End Try
End Sub
请大家帮一下.谢谢了.想让记录翻动时图片也即时更换.
|
|