搜索
bottom↓
回复: 6

用VB显示Access数据库中OLE长二进制格式字段

[复制链接]

出0入0汤圆

发表于 2009-3-26 22:40:38 | 显示全部楼层 |阅读模式
附件为Access数据库ourdev_428692.rar(文件大小:10K) (原文件名:20090318094206.rar)
上面附件为一个Access 数据库,该文件中有个ZoneInfo的表,表中Param段为OLE格式。请路上的高手指教下,如何显示。具体内容为一个产品的参数。先谢了。

阿莫论坛20周年了!感谢大家的支持与爱护!!

一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。

出0入0汤圆

 楼主| 发表于 2009-3-29 02:37:35 | 显示全部楼层
怎么没人回复啊,是不是太繁了啊。那位有什么关于这个的资料推荐一个,自己慢慢来,目前可以显示模块的名称,但就是不知怎么显示汉字。

出0入0汤圆

 楼主| 发表于 2009-3-29 02:37:38 | 显示全部楼层
怎么没人回复啊,是不是太繁了啊。那位有什么关于这个的资料推荐一个,自己慢慢来,目前可以显示模块的名称,但就是不知怎么显示汉字。

出0入0汤圆

 楼主| 发表于 2009-3-30 00:23:14 | 显示全部楼层
郁闷啊,

出330入0汤圆

发表于 2009-3-30 10:08:24 | 显示全部楼层
不妨到CSDN上去问,毕竟那里是搞纯软件开发的。这里大多是硬件起家的。


VB.NET 操作 ACCESS OLE 字段内容-.NET教程,VB.Net语言2009-03-21 16:54数据库结构:
--------------------------------------
test.mdb [放在bin目录下]
表 test(id 自动编号, img ole)
----------------------------------------------

代码:
----------------------------------------------------
使用 一个 openfiledialog ,两个 picturebox

----------------------------------------------------------------------
imports system.io
public class form1
inherits system.windows.forms.form

dim cnn as data.oledb.oledbconnection

private sub button4_click(byval sender as system.object, byval e as system.eventargs) handles button4.click
me.dispose(true)
end sub

private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click
if openfiledialog1.showdialog = dialogresult.ok then
picturebox1.image = image.fromfile(openfiledialog1.filename)
end if
end sub

private sub dbinit()
try
cnn = new data.oledb.oledbconnection("provider=microsoft.jet.oledb.4.0;data source=" & application.startuppath & "\test.mdb")
cnn.open()
catch exp as oledb.oledbexception
msgbox(exp.message)
end
end try
end sub

private sub dbrelease()
cnn.close()
cnn = nothing
end sub

private sub button2_click(byval sender as system.object, byval e as system.eventargs) handles button2.click
if picturebox1.image is nothing then
msgbox("请先选择图片", msgboxstyle.exclamation)
exit sub
end if
dim fs as filestream = new filestream(openfiledialog1.filename, filemode.open, fileaccess.read)
dim bt(fs.length) as byte
fs.read(bt, 0, fs.length)
fs.close()
fs = nothing
dim olecmd as oledb.oledbcommand = new oledb.oledbcommand
dbinit()
olecmd.connection = cnn
olecmd.commandtype = commandtype.text
olecmd.commandtext = "insert into test (img) values (@img)"
olecmd.parameters.add("@img", oledb.oledbtype.binary).value = bt
olecmd.executenonquery()
olecmd = nothing
dbrelease()
msgbox("图片插入成功")
end sub

private sub button3_click(byval sender as system.object, byval e as system.eventargs) handles button3.click
dim olecmd as oledb.oledbcommand = new oledb.oledbcommand("select img from test where id=1")
olecmd.commandtype = commandtype.text
dbinit()
olecmd.connection = cnn
dim dr as oledb.oledbdatareader = olecmd.executereader(commandbehavior.singlerow)
if dr.read then
if not isdbnull(dr.item(0)) then
dim bt() as byte = dr.item(0)
dim ms as memorystream = new memorystream(bt)
picturebox2.image = image.fromstream(ms)
else
msgbox("无图片")
end if
else
msgbox("无数据")
end if
dr.close()
dr = nothing
olecmd = nothing
dbrelease()
end sub
end class

出1070入962汤圆

发表于 2009-3-30 10:10:22 | 显示全部楼层
赞同楼上的观点,一些软件问题到CSDN去,基本不用提问,搜一些都是大把的答案和例程。

出0入0汤圆

 楼主| 发表于 2009-3-30 21:23:06 | 显示全部楼层
谢谢人楼上2位的解答,用GOOGLE和BAIDU搜过问的人很多,就是没答案。
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-5-20 19:14

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表