将图像存储在vb.net中的数据库中 [英] store image in database in vb.net

查看:83
本文介绍了将图像存储在vb.net中的数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在vb.net的数据库中存储图像?

how to store an image in database in vb.net?

推荐答案

您是否尝试搜索答案或手册? CodeProject文章提供的信息远远不够:
使用Microsoft .NET从SQL Server存储和检索图像 [ ^ ],
C#从数据库保存和加载图像 [ ^ ],
C#相册查看器 [ http://bit.ly/GD1Rix [ ^ ],
Did you try to search for the answer or a manual? CodeProject articles along provide more than enough information:
Storing and Retrieving Images from SQL Server using Microsoft .NET[^],
C# Save and Load Image from Database[^],
C# Photo Album Viewer[^].

Find some more if you want:
http://bit.ly/GD1Rix[^],
http://www.codeproject.com/search.aspx?doctypeid=1%3b5&q=store+image+in+database+%28%22.NET%22+OR+%22VB.NET%22%29[^].

—SA



这是示例代码


Hi,
Here is a sample code


Try
                    con.ConnectionString = str
                    con.Open()
                    Dim cmd As SqlCommand = New SqlCommand("insert into Empdetails(Image) values(@ImageData)", cn)
                    ' Add code for other Parameter
                    ' Code for Image Parameter
                    Dim param As New SqlParameter("@ImageData", SqlDbType.VarBinary)
                    Dim ImageData As Byte() = IO.File.ReadAllBytes(PictureBox1.ImageLocation)
                    param.Value = ImageData
                    cmd.Parameters.Add(param)
                    cmd.ExecuteNonQuery()
                    MsgBox("Added!")
                Catch ex As Exception
                    MsgBox(ex.Message)
                Finally
                    con.Close()
                End Try


这篇关于将图像存储在vb.net中的数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆