标题:实时错误481,无效图片
只看楼主
henshai
Rank: 1
等 级:新手上路
帖 子:69
专家分:0
注 册:2007-1-11
 问题点数:0 回复次数:24 
实时错误481,无效图片
完全参照百度给的代码的,为什么还错
在access里面的photo的属性是ole
Sub ReadFile()
Dim Stm As New ADODB.Stream
Dim Cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strCnn As String
Dim detail As String
FrmQuery.DataGrid1.Col = 1
detail = FrmQuery.DataGrid1.Text
Set rs = New ADODB.Recordset

strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & _
App.Path & "\GROUP1.mdb"
Cnn.Open strCnn
rs.Open " select Photo from StdInfo where Name = '" & detail & "'", Cnn, adOpenKeyset, adLockReadOnly
'保存到文件
Set Stm = New ADODB.Stream
With Stm
  .Mode = adModeReadWrite
  .Type = adTypeBinary
  .Open
  .Write rs("Photo")
  .SaveToFile App.Path + "\PhotoTemp.jpg"
End With
'显示图片
Picture1.Picture = LoadPicture(App.Path + "\PhotoTemp.jpg")
rs.Close
Stm.Close
Set rs = Nothing
Set Cnn = Nothing
Set Stm = Nothing
End Sub

[[italic] 本帖最后由 henshai 于 2007-12-1 13:19 编辑 [/italic]]
搜索更多相关主题的帖子: 百度 Microsoft 实时 Dim New 
2007-12-01 13:11
henshai
Rank: 1
等 级:新手上路
帖 子:69
专家分:0
注 册:2007-1-11
得分:0 
自己顶
2007-12-01 14:07
hnzz_wgf
Rank: 1
等 级:新手上路
帖 子:81
专家分:0
注 册:2007-11-21
得分:0 
支持一下
2007-12-01 14:32
henshai
Rank: 1
等 级:新手上路
帖 子:69
专家分:0
注 册:2007-1-11
得分:0 
谁来帮帮我
2007-12-01 15:57
hnzz_wgf
Rank: 1
等 级:新手上路
帖 子:81
专家分:0
注 册:2007-11-21
得分:0 
Dim Cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strCnn As String
Dim detail As String
Set rs = New ADODB.Recordset
Dim bit() As Byte

strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & _
App.Path & "\GROUP1.mdb"
Cnn.Open strCnn
rs.Open " select Photo from StdInfo where Name = '" & detail & "'", Cnn, adOpenKeyset, adLockReadOnly
'保存到文件
If rs.RecordCount > 0 Then
   mfile = App.Path + "\PhotoTemp.jpg"
   bit() = "" & rs.Fields("Photo")
   Open mfile For Binary As #1
   Put #1, , bit()
   Close #1

'显示图片
Picture1.Picture = LoadPicture(App.Path + "\PhotoTemp.jpg")
End If
rs.Close
Set rs = Nothing
Set Cnn = Nothing
2007-12-01 17:13
henshai
Rank: 1
等 级:新手上路
帖 子:69
专家分:0
注 册:2007-1-11
得分:0 
大虾,没有报错,也没有显示啊
没有生成phototemp.jpg文件,怎么读出来啊?
谢谢
2007-12-01 17:24
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
得分:0 
Sub ReadFile()
Dim Stm As New ADODB.Stream
Dim Cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strCnn As String
Dim detail As String
FrmQuery.DataGrid1.Col = 1
detail = FrmQuery.DataGrid1.Text
Set rs = New ADODB.Recordset

strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & _
App.Path & "\GROUP1.mdb"
Cnn.Open strCnn
rs.cursorlocation=aduseclient
rs.Open " select Photo from StdInfo where Name = '" & detail & "'", Cnn, adOpenKeyset, adLockReadOnly
msgbox "共有" & rs.recordcount & "条记录"
'保存到文件
Set Stm = New ADODB.Stream
With Stm
  .Mode = adModeReadWrite
  .Type = adTypeBinary
  .Open
  .Write rs("Photo")
  .SaveToFile App.Path + "\PhotoTemp.jpg"
End With
'显示图片
Stm.Close
Picture1.Picture = LoadPicture(App.Path + "\PhotoTemp.jpg")
rs.Close
Set rs = Nothing
Set Cnn = Nothing
Set Stm = Nothing
End Sub

我的msn: myfend@
2007-12-01 17:29
henshai
Rank: 1
等 级:新手上路
帖 子:69
专家分:0
注 册:2007-1-11
得分:0 
共一条记录,还是 ‘481’无效图片
2007-12-01 17:40
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
得分:0 
你的Photo是怎么添加进去的?.
打开Access的时候..photo字段是否显示长二进制格式?..

我的msn: myfend@
2007-12-01 17:42
henshai
Rank: 1
等 级:新手上路
帖 子:69
专家分:0
注 册:2007-1-11
得分:0 
生成了phototemp了,但是直接双击打开,什么也没有
但是文件大小却是2m
2007-12-01 17:44



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-189715-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015230 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved