可以了吗 不行的话给我留言 我再发个完整的给你 QQ:262050611
Dim Myset As DataSet
Dim Myadp As OleDbDataAdapter
Dim Opendia As New OpenFileDialog
Opendia.Filter = "Image File(*.JPG;*.BMP;*.JPEG)|*.JPG;*.BMP;*.JPEG"
Dim result As DialogResult = Opendia.ShowDialog
If result = DialogResult.Cancel Then
Exit Sub
End If
Dim Filename As String = Opendia.FileName
Dim Mycon As New OleDbConnection
Mycon.ConnectionString = "provider=Microsoft.JET.OLEDB.4.0;data source=" & Application.StartupPath & "\image.mdb"
Mycon.Open()
Myadp = New OleDbDataAdapter("select * from photo", Mycon)
Myset = New DataSet
Myadp.Fill(Myset, "Pho")
Dim FS As FileStream
FS = New FileStream(Filename, FileMode.Open)
Dim Filestream As New BinaryReader(FS)
Dim Myimg As Byte()
Myimg = Filestream.ReadBytes(FS.Length)
picbox.Image = Image.FromStream(FS)
Try
Dim Mycmd As New OleDbCommand
Mycmd.Connection = Mycon
Mycmd.CommandText = "insert into photo([image]) values (@image)"
Mycmd.CommandType = CommandType.Text
Dim MyP As OleDbParameter = Mycmd.Parameters.Add("@image", OleDbType.LongVarBinary)
MyP.Value = Myimg
Mycmd.ExecuteNonQuery()
Catch ex As SqlException
MsgBox(ex.Message)
End Try
Filestream.Close()
FS.Close()
Mycon.Close()
End Sub
Dim Myset1 As New DataSet
Dim FS As New FileStream("Qing", FileMode.Create)
Dim Stream1 As New BinaryWriter(FS)
Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem4.Click
Dim Mycon As New OleDbConnection("provider=Microsoft.JET.OLEDB.4.0;data source=" & Application.StartupPath & "\image.mdb")
Mycon.Open()
Dim myadp As New OleDbDataAdapter("Select * from Photo", Mycon)
myadp.Fill(Myset1, "Pho")
Stream1.Write(Myset1.Tables("Pho").Rows(0).Item("Image"))
picbox.Image = Image.FromStream(FS)
Stream1.Close()
FS.Close()
Mycon.Close()
Kill("qing")