专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »VB教程 » vb6数据库:用VB6读写数据库里面地图片 »正文

vb6数据库:用VB6读写数据库里面地图片

来源: 发布时间:星期四, 2009年2月12日 浏览:118次 评论:0



网上冲浪更快更爽下载带有 Google 工具栏 Firefox


Person.Height + Height - ScaleHeight
If hgt < 1440 Then hgt = 1440
Height = hgt

Kill file_name
Screen.MousePoer = vbDefault
End Sub

Private Sub mnuRecordAdd_Click
Dim rs As ADODB.Record
Dim person_name As String
Dim file_num As String
Dim file_length As String
Dim s As Byte
Dim num_blocks As Long
Dim left_over As Long
Dim block_num As Long

person_name = InputBox(\"Name\")
If Len(person_name) = 0 Then Exit Sub

dlgPicture.Flags = _
cdlOFNFileMustExist Or _
cdlOFNHideReadOnly Or _
cdlOFNExplorer
dlgPicture.CancelError = True
dlgPicture.Filter = \"Graphics Files|*.bmp;*.ico;*.jpg;*.g\"

On Error Resume Next
dlgPicture.ShowOpen
If Err.Number = cdlCancel Then
Exit Sub
ElseIf Err.Number <> 0 Then
MsgBox \"Error \" & Format$(Err.Number) & _
\" selecting file.\" & vbCrLf & Err.Description
Exit Sub
End If

注释: Open the picture file.
file_num = FreeFile
Open dlgPicture.FileName For Binary Access Read As #file_num

file_length = LOF(file_num)
If file_length > 0 Then
num_blocks = file_length / BLOCK_SIZE
left_over = file_length Mod BLOCK_SIZE

Set rs = New ADODB.Record
rs.CursorType = adOpenKey
rs.LockType = adLockOptimistic
rs.Open \"Select Name, Picture, FileLength FROM People\", m_DBConn

rs.AddNew
rs!Name = person_name
rs!FileLength = file_length

ReDim s(BLOCK_SIZE)
For block_num = 1 To num_blocks
Get #file_num, , s
rs!Picture.AppendChunk s
Next block_num

If left_over > 0 Then
ReDim s(left_over)
Get #file_num, , s
rs!Picture.AppendChunk s
End If

rs.Update
Close #file_num

lstPeople.AddItem person_name
lstPeople.Text = person_name
End If
End Sub  


0

相关文章

读者评论

发表评论

  • 昵称:
  • 内容: