我这样定义:Dim adoStream As New ADODB.Stream,为什么ADODB.后没有stream属性?我是想做图片存储的.在线等待,结帐

lindaShy 2003-08-18 04:54:12
我这样定义:Dim adoStream As New ADODB.Stream,为什么ADODB.后没有stream属性?我是想做图片存储的.在线等待,结帐

...全文
89 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
lihonggen0 2003-08-18
  • 打赏
  • 举报
回复
最直接的办法:
引用--->Microsoft ActiveX Data Object 2.5



------------------------
老办法就是用appendChunk

Public Sub AppendChunkX()

Dim cn As ADODB.Connection
Dim rstPubInfo As ADODB.Recordset
Dim strCn As String
Dim strPubID As String
Dim strPRInfo As String
Dim lngOffset As Long
Dim lngLogoSize As Long
Dim varLogo As Variant
Dim varChunk As Variant

Const conChunkSize = 100

' Open a connection.
Set cn = New ADODB.Connection
strCn = "Server=srv;Database=pubs;UID=sa;Pwd=;"

cn.Provider = "sqloledb"
cn.Open strCn

'Open the pub_info_x table.
Set rstPubInfo = New ADODB.Recordset
rstPubInfo.CursorType = adOpenDynamic
rstPubInfo.LockType = adLockOptimistic
rstPubInfo.Open "pub_info_x", cn, , , adCmdTable

'Prompt for a logo to copy.
strMsg = "Available logos are : " & vbCr & vbCr

Do While Not rstPubInfo.EOF
strMsg = strMsg & rstPubInfo!pub_id & vbCr & _
Left(rstPubInfo!pr_info,
InStr(rstPubInfo!pr_info, ",") - 1) & vbCr & vbCr
rstPubInfo.MoveNext
Loop

strMsg = strMsg & "Enter the ID of a logo to copy:"
strPubID = InputBox(strMsg)

' Copy the logo to a variable in chunks.
rstPubInfo.Filter = "pub_id = '" & strPubID & "'"
lngLogoSize = rstPubInfo!logo.ActualSize
Do While lngOffset < lngLogoSize
varChunk = rstPubInfo!logo.GetChunk(conChunkSize)
varLogo = varLogo & varChunk
lngOffset = lngOffset + conChunkSize
Loop

' Get data from the user.
strPubID = Trim(InputBox("Enter a new pub ID:"))
strPRInfo = Trim(InputBox("Enter descriptive text:"))

' Add a new record, copying the logo in chunks.
rstPubInfo.AddNew
rstPubInfo!pub_id = strPubID
rstPubInfo!pr_info = strPRInfo
lngOffset = 0 ' Reset offset.

Do While lngOffset < lngLogoSize
varChunk = LeftB(RightB(varLogo, lngLogoSize - _
lngOffset),conChunkSize)
rstPubInfo!logo.AppendChunk varChunk
lngOffset = lngOffset + conChunkSize
Loop

rstPubInfo.Update

' Show the newly added data.
MsgBox "New record: " & rstPubInfo!pub_id & vbCr & _
"Description: " & rstPubInfo!pr_info & vbCr & _
"Logo size: " & rstPubInfo!logo.ActualSize

rstPubInfo.Close
cn.Close

End Sub



lihonggen0 2003-08-18
  • 打赏
  • 举报
回复
最直接的办法:
引用--->Microsoft ActiveX Data Object 2.5



------------------------
老办法就是用appendChunk

Public Sub AppendChunkX()

Dim cn As ADODB.Connection
Dim rstPubInfo As ADODB.Recordset
Dim strCn As String
Dim strPubID As String
Dim strPRInfo As String
Dim lngOffset As Long
Dim lngLogoSize As Long
Dim varLogo As Variant
Dim varChunk As Variant

Const conChunkSize = 100

' Open a connection.
Set cn = New ADODB.Connection
strCn = "Server=srv;Database=pubs;UID=sa;Pwd=;"

cn.Provider = "sqloledb"
cn.Open strCn

'Open the pub_info_x table.
Set rstPubInfo = New ADODB.Recordset
rstPubInfo.CursorType = adOpenDynamic
rstPubInfo.LockType = adLockOptimistic
rstPubInfo.Open "pub_info_x", cn, , , adCmdTable

'Prompt for a logo to copy.
strMsg = "Available logos are : " & vbCr & vbCr

Do While Not rstPubInfo.EOF
strMsg = strMsg & rstPubInfo!pub_id & vbCr & _
Left(rstPubInfo!pr_info,
InStr(rstPubInfo!pr_info, ",") - 1) & vbCr & vbCr
rstPubInfo.MoveNext
Loop

strMsg = strMsg & "Enter the ID of a logo to copy:"
strPubID = InputBox(strMsg)

' Copy the logo to a variable in chunks.
rstPubInfo.Filter = "pub_id = '" & strPubID & "'"
lngLogoSize = rstPubInfo!logo.ActualSize
Do While lngOffset < lngLogoSize
varChunk = rstPubInfo!logo.GetChunk(conChunkSize)
varLogo = varLogo & varChunk
lngOffset = lngOffset + conChunkSize
Loop

' Get data from the user.
strPubID = Trim(InputBox("Enter a new pub ID:"))
strPRInfo = Trim(InputBox("Enter descriptive text:"))

' Add a new record, copying the logo in chunks.
rstPubInfo.AddNew
rstPubInfo!pub_id = strPubID
rstPubInfo!pr_info = strPRInfo
lngOffset = 0 ' Reset offset.

Do While lngOffset < lngLogoSize
varChunk = LeftB(RightB(varLogo, lngLogoSize - _
lngOffset),conChunkSize)
rstPubInfo!logo.AppendChunk varChunk
lngOffset = lngOffset + conChunkSize
Loop

rstPubInfo.Update

' Show the newly added data.
MsgBox "New record: " & rstPubInfo!pub_id & vbCr & _
"Description: " & rstPubInfo!pr_info & vbCr & _
"Logo size: " & rstPubInfo!logo.ActualSize

rstPubInfo.Close
cn.Close

End Sub



lesong 2003-08-18
  • 打赏
  • 举报
回复
说错了,是Field 或 Parameter 对象的appendChunk方法,专门用来处理二进制数据
lesong 2003-08-18
  • 打赏
  • 举报
回复
说错了,是Field 或 Parameter 对象的appendChunk方法,专门用来处理二进制数据
lesong 2003-08-18
  • 打赏
  • 举报
回复
用recordset对象的AppendChunk方法,很好用
射天狼 2003-08-18
  • 打赏
  • 举报
回复
写错了,把
Open "图片路径" For Binary Access Write As #1
Put #1, , lb_Wd
Close #1

改成

Open "图片路径" For Binary Access Read As #1
Get #1, , lb_Wd
Close #1
jornet 2003-08-18
  • 打赏
  • 举报
回复
http://www.microsoft.com/downloads/details.aspx?familyid=b41304ca-874f-421d-8820-182f179779a4&languageid=f49e8428-7071-4979-8a67-3cffcb0c2524&displaylang=en

可以到这里取下载最新的:Microsoft Data Access Components (MDAC) 2.7

射天狼 2003-08-18
  • 打赏
  • 举报
回复
只有高版本的ADO控件才有STREAM数据流这个属性,不过存图片不一定非得用数据流,声明动态的BYTE数组也可以。
例如
Dim lb_Wd() As Byte
Dim rsWd As New ADODB.Recordset

Open "图片路径" For Binary Access Write As #1
Put #1, , lb_Wd
Close #1

rsWd.AddNew
rsWd!DAILIWENDANG.AppendChunk (rsWdDm!WENDANG.GetChunk(rsWdDm!WENDANG.ActualSize))
rsWd.Update
lihonggen0 2003-08-18
  • 打赏
  • 举报
回复

工程--->引用--->Microsoft ActiveX Data Object 2.5

必须2.5以上版本


微软的答案:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;258038

7,759

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧