高手给看是怎么产生的“读取列序号“0”的尝试无效。通过 CommandBehavior.SequentialAccess 只能读取“2”或更大的列序号"

zhangwanglan 2012-05-27 01:00:04
我是把数据库里的图片全部导入到wode文件夹下,提示错误“读取列序号“0”的尝试无效。通过 CommandBehavior.SequentialAccess 只能读取“2”或更大的列序号”是怎么回事,高手帮忙看下
 Dim db As String = "Data Source=lenovo-pc;Initial Catalog=wode;User ID=sa;password=123456"
Using con As New SqlConnection(db)

Dim com As New SqlCommand
com.CommandText = "select * from 图片"
com.Connection = con
Dim buffer As Integer = 10000
Dim outbyte(buffer - 1) As Byte
Dim retval As Long
Dim startindex As Long = 0
Dim id As String = ""
con.Open()
Using Myreader As SqlDataReader = com.ExecuteReader(CommandBehavior.SequentialAccess)
Do While Myreader.Read()
Dim h As String = Myreader.GetString(1)
Using fa As New FileStream("E:\wode\" & h & ".jpg", FileMode.OpenOrCreate, FileAccess.Write)
Using bw As New BinaryWriter(fa)
startindex = 0
retval = Myreader.GetBytes(0, startindex, outbyte, 0, buffer)(读取列序号“0”的尝试无效。通过 CommandBehavior.SequentialAccess 只能读取“2”或更大的列序号)
Do While retval = buffer
bw.Write(outbyte)
bw.Flush()
startindex += buffer
retval = Myreader.GetBytes(0, startindex, outbyte, 0, buffer)
Loop
bw.Write(outbyte, 0, CType(retval - 1, Integer))
bw.Flush()
End Using
End Using
Loop
MsgBox("导入长弓")

End Using
End Using

数据库里的列表
数据库里有两列,一个图片在第一列,文件名在第二列
...全文
60 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

16,718

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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