16,718
社区成员
发帖
与我相关
我的任务
分享 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