Dim bmp As New Bitmap("打开图片的路径")
创新互联是一家以网站设计建设,小程序定制开发、网站开发设计,网络软件产品开发,企业互联网推广服务为主的民营科技公司。主要业务涵盖:为客户提供网站策划、网站设计、网站开发、域名申请、网站优化排名、友情链接等服务领域。凭借建站老客户口碑做市场,建设网站时,根据市场搜索规律和搜索引擎的排名收录规律编程,全力为建站客户设计制作排名好的网站,深受老客户认可和赞誉。
bmp.Save("保存图片的路径")
Dim t As New TextBox()
Dim p As New PictureBox
p.Image = bmp 'picture等支持image的控件。
t.CreateGraphics.DrawImage(bmp, New Point) '文本控件。
Me.BackgroundImage = bmp '窗体
#Region "二进制文件的存储函数" Public Function BinaryToFile(ByRef TableRowColItem As Object, ByVal FileName As String) As Boolean Dim data As Byte() = TableRowColItem
Dim myfilestream As New System.IO.FileStream(FileName, IO.FileMode.Create)
myfilestream.Write(data, 0, data.Length)
myfilestream.Close()
Return True
End Function Public Function BinaryToImage(ByRef TableRowColItem As Object, ByRef image As Image) As Boolean Dim data As Byte() = TableRowColItem Dim imgStream As New System.IO.MemoryStream '(data)
imgStream.Write(data, 0, data.Length)
image = System.Drawing.Image.FromStream(imgStream)
imgStream.Close()
imgStream.Dispose() Return True
End Function
Public Function BinaryFromFile(ByVal FileName As String, ByRef TableRowColItem As Object) As Boolean Using myfilestream As New FileStream(FileName, FileMode.Open, FileAccess.Read)
Dim data() As Byte
ReDim data(myfilestream.Length - 1)
myfilestream.Read(data, 0, myfilestream.Length)
myfilestream.Close()
TableRowColItem = data End Using
Return True
End Function Public Function BinaryFromImage(ByRef Image As Image, ByRef TableRowColItem As Object) As Boolean
Dim imgStream As New MemoryStream
Dim b As New Bitmap(Image) b.Save(imgStream, System.Drawing.Imaging.ImageFormat.Jpeg) Dim data As Byte() = imgStream.GetBuffer
TableRowColItem = data
data = TableRowColItem
imgStream.Close()
imgStream.Dispose() Return True
End Function Public Function BinaryFromImage(ByVal Image As Image, ByRef TableRowColItem As Object, ByVal imgFormat As System.Drawing.Imaging.ImageFormat) As Boolean
Dim imgStream As New MemoryStream
'Image.Save(imgStream, imgFormat)
'Dim b As New Bitmap(Image)
'b.Save("c:\a.bmp", imgFormat)
'b.Save("c:\a.bmp", imgFormat) Dim data As Byte() = imgStream.GetBuffer TableRowColItem = data
data = TableRowColItem
imgStream.Close()
Return True
End Function
#End Region
都是只保存路径的,把图片放到一个专用的文件夹下,读取的时候,从路径得图片
一个参考过程,你试试 这里写下一个过程为: insert into pub_infor values('1234',0x,'this is a sample') 然后读入图片: sp_textcopy @srvname = '.', @login = 'sa', @password = 'sa', @dbname = 'pubs', @tbname = 'pub_info', @colname = 'logo', @filename = 'c:\picture.bmp', @whereclause = " WHERE pub_id='1234' ", @direction = 'I' 读出为: sp_textcopy @srvname = '.', @login = 'sa', @password = 'sa', @dbname = 'pubs', @tbname = 'pub_info', @colname = 'logo', @filename = 'D:\picture.bmp', @whereclause = " WHERE pub_id='1234' ", @direction = 'O' 清空:update 表 set 列=null 最后注意事项:因为filename的字符长度只有30个:即: @filename varchar (30), 所以实际应用的时候最好改为255个,当含有比较长的路径的时候就会报错: ERROR: Augment 'xxx' unrecognize 还有参数的长度@exec_str varchar (255)也修改下比较好: 我改成了这样子: CREATE PROCEDURE sp_textcopy ( @srvname varchar (30), @login varchar (30), @password varchar (30), @dbname varchar (30), @tbname varchar (30), @colname varchar (30), @filename varchar (255), @whereclause varchar (40), @direction char(1)) AS DECLARE @exec_str varchar (400) SELECT @exec_str = 'textcopy /S ' + @srvname + ' /U ' + @login + ' /P ' + @password + ' /D ' + @dbname + ' /T ' + @tbname + ' /C ' + @colname + ' /W "' + @whereclause + '" /F ' + @filename + ' /' + @direction EXEC master..xp_cmdshell @exec_str 就只这样子了,感觉上T_SQL编程还是挺强大的,有时间应该好好学习下。 回答: 这里以SQL_server2000中的pubs数据库中的pub_info表为例来说说其中的过程:pub_info表包含:pub_id,logo,pr_info,其中logo属于image超长字段,应用存储过程奖图像存储在数据库的步骤包括: 1:首先:是插入一个列: 比如:insert into pub_infor values('1234',0x,'this is a sample')其中0x只是为了确保image字段不能为空:因为下面的存储过程:textcopy 用textcopy把图片或者文件拷贝到image类型字段之前,image类型的字段不能为空。先插入0x(或者0x0)到这个字段,然后就可以用textcopy了。 否则就会报这样的错误: ERROR: Text or image pointer and timestamp retrieval failed. 2:接下来建立存储过程: CREATE PROCEDURE sp_textcopy ( @srvname varchar (30), @login varchar (30), @password varchar (30), @dbname varchar (30), @tbname varchar (30), @colname varchar (30), @filename varchar (30), @whereclause varchar (40), @direction char(1)) AS DECLARE @exec_str varchar (255) SELECT @exec_str = 'textcopy /S ' + @srvname + ' /U ' + @login + ' /P ' + @password + ' /D ' + @dbname + ' /T ' + @tbname + ' /C ' + @colname + ' /W "' + @whereclause + '" /F ' + @filename + ' /' + @direction EXEC master..xp_cmdshell @exec_str 说明: 其中xp_cmdshell: 以操作系统命令行解释器的方式执行给定的命令字符串,并以文本行方式返回任何输出。授予非管理用户执行 xp_cmdshell 的权限。我自己的理解是: textcopy就像是一个dos命令:就是说实际的文件copy命令是类似操作系统执行的。
采纳哦
有什么问题吗?
你哪里不会呀?
这问题简单的要命,你看看MSDN 或者编程的时候找找属性方法,根据提示都可以做出来吧,感觉你真的不像是学VB.NET的
如果TextBox1.Text包括了路径文件名;
PictureBox1.Image.Save(TextBox1.Text)
售后响应及时
7×24小时客服热线数据备份
更安全、更高效、更稳定价格公道精准
项目经理精准报价不弄虚作假合作无风险
重合同讲信誉,无效全额退款