18 个解决方案
#1
你必须要以只读方式打开那个图片,你是怎么做的?给代码~~~~~
#2
数据库是如何连接的?
#3
PictureBox.Image=Refresh;
#4
你的图片字段存的是二进制数据,还是图片的路径呀.最好把你的代码帖出来.呵呵.
#5
数据库用的是MSSQL,图片字段是image类型.
picTIMAGE2.Image = dttTable.Rows(0)(8)'binary数据
用这种方法读取一次数据后,如果在读取其他的记录或再次读取本条记录,就会报图片正在使用的错误信息!如果将PictureBox重新选取一张图片再读入数据则无上述情况!
PictureBox.Image=Refresh不能解决我的问题,我是已只读方式将图片保存进数据库的,怎么用只读方式从数据库中读出图片呢?
picTIMAGE2.Image = dttTable.Rows(0)(8)'binary数据
用这种方法读取一次数据后,如果在读取其他的记录或再次读取本条记录,就会报图片正在使用的错误信息!如果将PictureBox重新选取一张图片再读入数据则无上述情况!
PictureBox.Image=Refresh不能解决我的问题,我是已只读方式将图片保存进数据库的,怎么用只读方式从数据库中读出图片呢?
#6
‘’‘我是用access的,你试一下。
打开
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim data As Byte()
Dim sql As String
sql = "select * from bmp "
adocmd = New OleDbDataAdapter(sql, "provider=microsoft.jet.oledb.4.0;data source=E:\Vb.net\图像保存到数据库中\db1.mdb")
adocmd.Fill(ds, "bmp")
mytable = ds.Tables.Item(0)
data = ds.Tables(0).Rows(0).Item(0)
' Dim app As String = Application.StartupPath
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")
End Sub
保存:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim mystr As New System.IO.FileStream(bmpstr, IO.FileMode.Open)
Dim data As Byte()
ReDim data(mystr.Length - 1)
mystr.Read(data, 0, mystr.Length)
mystr.Close()
Dim sql As String
sql = "select * from bmp "
adocmd = New OleDbDataAdapter(sql, "provider=microsoft.jet.oledb.4.0;data source=E:\Vb.net\图像保存到数据库中\db1.mdb")
adocmd.Fill(ds, "bmp")
mytable = ds.Tables.Item(0)
Dim newmyrow As DataRow
newmyrow = mytable.NewRow
newmyrow.Item(0) = data
mytable.Rows.Add(newmyrow)
'adocmd.Update(mytable.GetChanges)
mytable.GetChanges()
cmd = New OleDbCommandBuilder(adocmd)
adocmd.Update(ds, "bmp")
MsgBox("添加图像成功)")
End Sub
打开
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim data As Byte()
Dim sql As String
sql = "select * from bmp "
adocmd = New OleDbDataAdapter(sql, "provider=microsoft.jet.oledb.4.0;data source=E:\Vb.net\图像保存到数据库中\db1.mdb")
adocmd.Fill(ds, "bmp")
mytable = ds.Tables.Item(0)
data = ds.Tables(0).Rows(0).Item(0)
' Dim app As String = Application.StartupPath
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")
End Sub
保存:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim mystr As New System.IO.FileStream(bmpstr, IO.FileMode.Open)
Dim data As Byte()
ReDim data(mystr.Length - 1)
mystr.Read(data, 0, mystr.Length)
mystr.Close()
Dim sql As String
sql = "select * from bmp "
adocmd = New OleDbDataAdapter(sql, "provider=microsoft.jet.oledb.4.0;data source=E:\Vb.net\图像保存到数据库中\db1.mdb")
adocmd.Fill(ds, "bmp")
mytable = ds.Tables.Item(0)
Dim newmyrow As DataRow
newmyrow = mytable.NewRow
newmyrow.Item(0) = data
mytable.Rows.Add(newmyrow)
'adocmd.Update(mytable.GetChanges)
mytable.GetChanges()
cmd = New OleDbCommandBuilder(adocmd)
adocmd.Update(ds, "bmp")
MsgBox("添加图像成功)")
End Sub
#7
Dim data As Byte()
data =dttTable.Rows(0)(8)'做到这步的时候,报出类型不对的错误信息,不能再进行下去
data =dttTable.Rows(0)(8)'做到这步的时候,报出类型不对的错误信息,不能再进行下去
#8
Picturebox.image.dispose
picturebox.refresh
picturebox.refresh
#9
Picturebox.image.dispose后如果要保存的话,就不能将图片保存进数据库了!
我用变量存好图片后,再Picturebox.image.dispose但所有程序运行完(赋值已成功),光标跳到
Public Class frmMntSheama(窗口定义头)报出使用的参数无效的错!
变量如下:
Public imgImage1 As New GrapeCity.Win.Editors.ImageEditor
赋值程序如下:
If IsDBNull(dttTable.Rows(0)(7)) Then
picTIMAGE1.Image = Nothing
Else
picTIMAGE1.Image = dttTable.Rows(0)(7)
imgImage1.Image = picTIMAGE1.Image
picTIMAGE1.Image.Dispose()
End If
我用变量存好图片后,再Picturebox.image.dispose但所有程序运行完(赋值已成功),光标跳到
Public Class frmMntSheama(窗口定义头)报出使用的参数无效的错!
变量如下:
Public imgImage1 As New GrapeCity.Win.Editors.ImageEditor
赋值程序如下:
If IsDBNull(dttTable.Rows(0)(7)) Then
picTIMAGE1.Image = Nothing
Else
picTIMAGE1.Image = dttTable.Rows(0)(7)
imgImage1.Image = picTIMAGE1.Image
picTIMAGE1.Image.Dispose()
End If
#10
我做了一个类,可以和数据库的IMAGE字段捆绑,把你的邮箱给我。
#11
我说错了,使我有一个类,但不是我做的。是WWWFIND的。
#12
greenhand_stone@citiz.net,谢了!
#13
up
#14
现在终于发现问题的所在,哪位高手能指点,如何在PictureBox中设置就能以只读方式读取数据库中的图片?
#15
呵呵
#16
http://expert.csdn.net/Expert/topic/2461/2461896.xml?temp=.7170374
#17
此问题本人已作回答,详见:
http://expert.csdn.net/Expert/topic/2491/2491338.xml?temp=.9606745
创建一个memorySteam的内存流将文件读到内存后关掉文件,再将流还原成Image就可以了:
im imgdatastream As IO.FileStream
Dim Fileinfo As New IO.FileInfo(ImgPath)
imgdatastream = IO.File.Open(ImgPath, IO.FileMode.Open, IO.FileAccess.ReadWrite)
Dim imgdatalen As Integer = Fileinfo.Length '定义每次读取字节的长度
Dim m_ImgData(imgdatalen) as byte '定义存储图片二进制的数组
'获取图片的字节数
imgdatastream.Read(m_ImgData, 0, imgdatalen)
'压缩指定路径下的图片并预览
Dim MemStream As New IO.MemoryStream(m_ImgData)
Me.PictureBox2.Image = Image.FromStream(MemStream)
http://expert.csdn.net/Expert/topic/2491/2491338.xml?temp=.9606745
创建一个memorySteam的内存流将文件读到内存后关掉文件,再将流还原成Image就可以了:
im imgdatastream As IO.FileStream
Dim Fileinfo As New IO.FileInfo(ImgPath)
imgdatastream = IO.File.Open(ImgPath, IO.FileMode.Open, IO.FileAccess.ReadWrite)
Dim imgdatalen As Integer = Fileinfo.Length '定义每次读取字节的长度
Dim m_ImgData(imgdatalen) as byte '定义存储图片二进制的数组
'获取图片的字节数
imgdatastream.Read(m_ImgData, 0, imgdatalen)
'压缩指定路径下的图片并预览
Dim MemStream As New IO.MemoryStream(m_ImgData)
Me.PictureBox2.Image = Image.FromStream(MemStream)
#18
唯一的不同之处:
'获取图片的字节数
dim m_ImgData() as byte
m_ImgData=row("Picture")
'压缩指定路径下的图片并预览
Dim MemStream As New IO.MemoryStream(m_ImgData)
Me.PictureBox2.Image = Image.FromStream(MemStream)
'获取图片的字节数
dim m_ImgData() as byte
m_ImgData=row("Picture")
'压缩指定路径下的图片并预览
Dim MemStream As New IO.MemoryStream(m_ImgData)
Me.PictureBox2.Image = Image.FromStream(MemStream)
#1
你必须要以只读方式打开那个图片,你是怎么做的?给代码~~~~~
#2
数据库是如何连接的?
#3
PictureBox.Image=Refresh;
#4
你的图片字段存的是二进制数据,还是图片的路径呀.最好把你的代码帖出来.呵呵.
#5
数据库用的是MSSQL,图片字段是image类型.
picTIMAGE2.Image = dttTable.Rows(0)(8)'binary数据
用这种方法读取一次数据后,如果在读取其他的记录或再次读取本条记录,就会报图片正在使用的错误信息!如果将PictureBox重新选取一张图片再读入数据则无上述情况!
PictureBox.Image=Refresh不能解决我的问题,我是已只读方式将图片保存进数据库的,怎么用只读方式从数据库中读出图片呢?
picTIMAGE2.Image = dttTable.Rows(0)(8)'binary数据
用这种方法读取一次数据后,如果在读取其他的记录或再次读取本条记录,就会报图片正在使用的错误信息!如果将PictureBox重新选取一张图片再读入数据则无上述情况!
PictureBox.Image=Refresh不能解决我的问题,我是已只读方式将图片保存进数据库的,怎么用只读方式从数据库中读出图片呢?
#6
‘’‘我是用access的,你试一下。
打开
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim data As Byte()
Dim sql As String
sql = "select * from bmp "
adocmd = New OleDbDataAdapter(sql, "provider=microsoft.jet.oledb.4.0;data source=E:\Vb.net\图像保存到数据库中\db1.mdb")
adocmd.Fill(ds, "bmp")
mytable = ds.Tables.Item(0)
data = ds.Tables(0).Rows(0).Item(0)
' Dim app As String = Application.StartupPath
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")
End Sub
保存:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim mystr As New System.IO.FileStream(bmpstr, IO.FileMode.Open)
Dim data As Byte()
ReDim data(mystr.Length - 1)
mystr.Read(data, 0, mystr.Length)
mystr.Close()
Dim sql As String
sql = "select * from bmp "
adocmd = New OleDbDataAdapter(sql, "provider=microsoft.jet.oledb.4.0;data source=E:\Vb.net\图像保存到数据库中\db1.mdb")
adocmd.Fill(ds, "bmp")
mytable = ds.Tables.Item(0)
Dim newmyrow As DataRow
newmyrow = mytable.NewRow
newmyrow.Item(0) = data
mytable.Rows.Add(newmyrow)
'adocmd.Update(mytable.GetChanges)
mytable.GetChanges()
cmd = New OleDbCommandBuilder(adocmd)
adocmd.Update(ds, "bmp")
MsgBox("添加图像成功)")
End Sub
打开
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim data As Byte()
Dim sql As String
sql = "select * from bmp "
adocmd = New OleDbDataAdapter(sql, "provider=microsoft.jet.oledb.4.0;data source=E:\Vb.net\图像保存到数据库中\db1.mdb")
adocmd.Fill(ds, "bmp")
mytable = ds.Tables.Item(0)
data = ds.Tables(0).Rows(0).Item(0)
' Dim app As String = Application.StartupPath
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")
End Sub
保存:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim mystr As New System.IO.FileStream(bmpstr, IO.FileMode.Open)
Dim data As Byte()
ReDim data(mystr.Length - 1)
mystr.Read(data, 0, mystr.Length)
mystr.Close()
Dim sql As String
sql = "select * from bmp "
adocmd = New OleDbDataAdapter(sql, "provider=microsoft.jet.oledb.4.0;data source=E:\Vb.net\图像保存到数据库中\db1.mdb")
adocmd.Fill(ds, "bmp")
mytable = ds.Tables.Item(0)
Dim newmyrow As DataRow
newmyrow = mytable.NewRow
newmyrow.Item(0) = data
mytable.Rows.Add(newmyrow)
'adocmd.Update(mytable.GetChanges)
mytable.GetChanges()
cmd = New OleDbCommandBuilder(adocmd)
adocmd.Update(ds, "bmp")
MsgBox("添加图像成功)")
End Sub
#7
Dim data As Byte()
data =dttTable.Rows(0)(8)'做到这步的时候,报出类型不对的错误信息,不能再进行下去
data =dttTable.Rows(0)(8)'做到这步的时候,报出类型不对的错误信息,不能再进行下去
#8
Picturebox.image.dispose
picturebox.refresh
picturebox.refresh
#9
Picturebox.image.dispose后如果要保存的话,就不能将图片保存进数据库了!
我用变量存好图片后,再Picturebox.image.dispose但所有程序运行完(赋值已成功),光标跳到
Public Class frmMntSheama(窗口定义头)报出使用的参数无效的错!
变量如下:
Public imgImage1 As New GrapeCity.Win.Editors.ImageEditor
赋值程序如下:
If IsDBNull(dttTable.Rows(0)(7)) Then
picTIMAGE1.Image = Nothing
Else
picTIMAGE1.Image = dttTable.Rows(0)(7)
imgImage1.Image = picTIMAGE1.Image
picTIMAGE1.Image.Dispose()
End If
我用变量存好图片后,再Picturebox.image.dispose但所有程序运行完(赋值已成功),光标跳到
Public Class frmMntSheama(窗口定义头)报出使用的参数无效的错!
变量如下:
Public imgImage1 As New GrapeCity.Win.Editors.ImageEditor
赋值程序如下:
If IsDBNull(dttTable.Rows(0)(7)) Then
picTIMAGE1.Image = Nothing
Else
picTIMAGE1.Image = dttTable.Rows(0)(7)
imgImage1.Image = picTIMAGE1.Image
picTIMAGE1.Image.Dispose()
End If
#10
我做了一个类,可以和数据库的IMAGE字段捆绑,把你的邮箱给我。
#11
我说错了,使我有一个类,但不是我做的。是WWWFIND的。
#12
greenhand_stone@citiz.net,谢了!
#13
up
#14
现在终于发现问题的所在,哪位高手能指点,如何在PictureBox中设置就能以只读方式读取数据库中的图片?
#15
呵呵
#16
http://expert.csdn.net/Expert/topic/2461/2461896.xml?temp=.7170374
#17
此问题本人已作回答,详见:
http://expert.csdn.net/Expert/topic/2491/2491338.xml?temp=.9606745
创建一个memorySteam的内存流将文件读到内存后关掉文件,再将流还原成Image就可以了:
im imgdatastream As IO.FileStream
Dim Fileinfo As New IO.FileInfo(ImgPath)
imgdatastream = IO.File.Open(ImgPath, IO.FileMode.Open, IO.FileAccess.ReadWrite)
Dim imgdatalen As Integer = Fileinfo.Length '定义每次读取字节的长度
Dim m_ImgData(imgdatalen) as byte '定义存储图片二进制的数组
'获取图片的字节数
imgdatastream.Read(m_ImgData, 0, imgdatalen)
'压缩指定路径下的图片并预览
Dim MemStream As New IO.MemoryStream(m_ImgData)
Me.PictureBox2.Image = Image.FromStream(MemStream)
http://expert.csdn.net/Expert/topic/2491/2491338.xml?temp=.9606745
创建一个memorySteam的内存流将文件读到内存后关掉文件,再将流还原成Image就可以了:
im imgdatastream As IO.FileStream
Dim Fileinfo As New IO.FileInfo(ImgPath)
imgdatastream = IO.File.Open(ImgPath, IO.FileMode.Open, IO.FileAccess.ReadWrite)
Dim imgdatalen As Integer = Fileinfo.Length '定义每次读取字节的长度
Dim m_ImgData(imgdatalen) as byte '定义存储图片二进制的数组
'获取图片的字节数
imgdatastream.Read(m_ImgData, 0, imgdatalen)
'压缩指定路径下的图片并预览
Dim MemStream As New IO.MemoryStream(m_ImgData)
Me.PictureBox2.Image = Image.FromStream(MemStream)
#18
唯一的不同之处:
'获取图片的字节数
dim m_ImgData() as byte
m_ImgData=row("Picture")
'压缩指定路径下的图片并预览
Dim MemStream As New IO.MemoryStream(m_ImgData)
Me.PictureBox2.Image = Image.FromStream(MemStream)
'获取图片的字节数
dim m_ImgData() as byte
m_ImgData=row("Picture")
'压缩指定路径下的图片并预览
Dim MemStream As New IO.MemoryStream(m_ImgData)
Me.PictureBox2.Image = Image.FromStream(MemStream)