将图像文件存储到数据库的最佳方法 [英] Best way to store image file to database
问题描述
我是一个新手,仍然在探索VB.NET 2010的无穷范围...我正在使用VB.Net,有没有人能建议(最好)将图像存储到ACCESS(.mdb)中的代码? )?
要求:
1.在VB中"处理此数据的最佳数据类型
2.处理此数据"ACCES"的最佳数据类型(当然,带有
的数据类型
最小的文件大小,因为我担心此类数据会吞噬大的
其存储量)
3.当然,VB中的示例代码在设置
时使用了以下代码
连接:
Hi, Im a newbie and still exploring the endless range of VB.NET 2010... I am using VB.Net, does anyone out there who can suggest a code (best)in storing a image to ACCESS (.mdb)?
Requirments:
1. Best data type to handle this data "in VB"
2. Best data type to handle this data "ACCES" (ofcourse the one with the
smallest file size since im concern that this type of data engulfs large
amounts of its storage)
3. Of course the sample code in VB, I used the following code in setting the
connection:
Imports System.Data.OleDb
Public Class dbs
Public Shared Function Connect() As OleDbConnection
Dim db As New OleDbConnection
db.ConnectionString = "PROVIDER = Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE = " & Application.StartupPath &
"\Database\Vault.mdb"
Return db
End Function
End Class
而且我随时使用以下代码来连接并打开数据库
And I use the following code at any time to connect and open to the database
Imports System.Data.OleDb
Public Class name
Private db As OleDbConnection
db = dbs.Connect
db.Open()
'code here... assuming pbPictureBoxName as the PictureBox
db.Close()
End Class
推荐答案
图像可以通过以下不同方式存储:
1-将它们存储为字节数组
2-在实际存储图像的位置存储图像的物理路径
3-存储为OLE对象.
如果我拥有图像存储空间,我更喜欢将图像存储为字节数组.以下链接将为您提供所需的详细信息:
http://social.msdn.microsoft.com /Forums/zh-CN/vbgeneral/thread/38fca0cc-e012-4934-ad8b-2f95c4e26cc4/ http://www.dreamincode.net/forums/topic/74114-a-really -simple-database/ [ ^ ]
希望对您有所帮助.
Images can be stored in following different ways:
1- Store them as byte array
2- store the physical path of the image where its actually stored
3- store as OLE object.
I prefer storing images as byte array if my owns the storage of the images. Following links would provide you the details you are looking for:
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/38fca0cc-e012-4934-ad8b-2f95c4e26cc4/
http://www.dreamincode.net/forums/topic/74114-a-really-simple-database/[^]
hope it helps.
这篇关于将图像文件存储到数据库的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!