呵呵,这个标题还差不多,让我忍不住想回贴。
“各位兄弟姐妹:小妹有一个问题在众多论坛上都无人发表(因无胆量)。请帮忙!”,这个我看了好几遍,说不清为什么不想回,反正是不想回。
'从数据库读取图片暂时存储为monkey.bmp,然后加载到image控件里面.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadPicFromDb.Click
Try
Dim data As Byte() = DataSet11.Tables(0).Rows(7).Item(3)
Dim myfilestream As New System.IO.FileStream(Application.StartupPath & "\monkey.bmp", IO.FileMode.Create)
myfilestream.Write(data, 0, data.Length)
myfilestream.Close()
PictureBox1.Image = New Bitmap(Application.StartupPath & "\monkey.bmp")
Catch
End Try
End Sub
'把C:\6.bmp写入库中,你可以改为自己的图片.
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InsertPicToDb.Click
Dim myfilestream As New System.IO.FileStream("c:\6.bmp", IO.FileMode.Open)
Dim data() As Byte
ReDim data(myfilestream.Length - 1)
myfilestream.Read(data, 0, myfilestream.Length)
myfilestream.Close()
DataSet11.Tables(0).Rows(7).Item(3) = data
SqlDataAdapter1.Update(DataSet11.GetChanges())
End Sub
前提条件是一定要正确连接数据库,并用SqlDataAdapter1.Fill(DataSet11)将数据读入数据集