使用VB.NET从Access数据库中检索OLE对象图像 [英] Retrieving OLE Object image from access database using VB.NET
问题描述
你好朋友,
我有问题从访问数据库中检索ole对象二进制数据到图片框,
Table_name:Bio_data_ND1
i有一个唯一的列名为:regno
然后是图片所在的列:picpath
实际我做了一点工作,但老实说它行为不端。我使用了这些代码:
Hello friend,
I am having problem retrieving ole object binary data from access database into picture box,
Table_name: Bio_data_ND1
i have a unique column called: regno
then column where the picture reside: picpath
actual i did a little work, but honestly it misbehaved. i used this codes:
Private Sub display_result_ND1()
Try
Dim adp As New OleDb.OleDbDataAdapter("select * FROM Bio_data_ND1 WHERE regno='" & TxtSearch.Text & "'", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\..\ResultPrc.mdb;Persist Security Info=True")
Dim ds As New DataSet
adp.Fill(ds, "Bio_data_ND1")
Dim bytes() As Byte = ds.Tables("Bio_data_ND1").Rows(0).Item("picpath")
Dim img As Image = Image.FromStream(New System.IO.MemoryStream(bytes))
PictureBox2.Image = img
Catch ex As Exception
MsgBox(ex.Message)
End Try
end sub
但是每当我尝试选择时,WHERE子句都不起作用它只给我存储在数据库中的最后一条记录,
i不知道我是否需要纠正这个错误
如果有的请求帮助。
谢谢。
but the WHERE clause is not working, whenever i try selecting it gives me only the last record stored in the database,
i dont know if the is a little mistake that i need to correct
if any please help.
thanks.
推荐答案
无论regno
数据类型,您应该使用以下内容:
No matter ofregno
data type, you should use something like this:
select * FROM Bio_data_ND1 WHERE regno=?
因为sql注入 [ ^ ]。然后使用以下命令调用此命令: OleDbParameterCollection。 AddWithValue方法 [ ^ ]
请参阅相似问题 [ ^ ]。
because of sql injection[^]. Then call this command with: OleDbParameterCollection.AddWithValue Method[^]
Please, see similar question[^].
这篇关于使用VB.NET从Access数据库中检索OLE对象图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!