我现在在课程设计,是关于数据库方面的,其中一个问题我和我的同学都不会,请高手帮忙。
  我们建了了一个“学生”的数据库,其中有一个“学生基本表”,其中是一些关于学生的基本
信息,如:姓名,性别,照片等。
  我的问题是:在连接数据库后,其他的都能显示出来,图片就是不能显示,怎么才能在程序运行时显示。

解决方案 »

  1.   

    读取图片是使用stream流,但是大图片要分块读取数据。
    Dim rs As New ADODB.Recordset
    Dim TempSql As New ADODB.Stream
    On Error GoTo ine
    With TempSql
         .Mode = adModeReadWrite   '文件流读写
         .Type = adTypeBinary      '以二进制格式存储
         .Open
         '.LoadFromFile ("c:\008.JPG")
    End With
    rs.Open "select top 1 * from MyPicture", conn, adOpenKeyset
    If rs.RecordCount > 0 Then
       Text1.Text = rs.Fields.Item("PictureName").Value
       TempSql.Write (rs.Fields.Item("Picture").Value)    '讲数据写入缓存ADO流
       TempSql.SaveToFile Text1.Text
       Picture1.Picture = LoadPicture(Text1.Text)
    End If
    rs.Close
    Call PicFit
    'Call PicF.smallPic(Text1.Text, Picture1, Picture2)
    Call smallPic
    GoTo inerr
    ine:
    MsgBox Err.Description, , "提示信息"
    inerr:
    Set rs = Nothing