这些程序是一个图像显示的程序,
Dim con As New ADODB.Connection
Private Sub Combo1_Click()      ' 点击图像下接列表
Dim rs As ADODB.Recordset
Dim b() As Byte
'从数据为中取数据
Set rs = con.Execute("select imageValue from images where imageName='" & Combo1.Text & "'")
If (Not rs.EOF) Then
    '将数据库中的数据写入到文件中
    '改变可变数组的大小
    ReDim b(rs.Fields(0).ActualSize)
    b = rs.Fields(0).Value
    '如果没有temp目录,产生一个新的目录
    If (Dir(App.Path & "/temp", vbDirectory) = Empty) Then
        MkDir (App.Path & "/temp")
    End If
    Dim filename As String
    filename = App.Path & "/temp" & "/" & Combo1.Texts
    Dim ch As Long
    ch = FreeFile
    Open filename For Binary As #ch
        Put #ch, , b
    Close #ch
    Picture1.Picture = LoadPicture(filename)
    rs.Close
Else
   MsgBox "没有对应的数据"
End If
End Sub
Private Sub Command1_Click()  '打開
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.filename
End Sub
Private Sub Command2_Click()  '写入数据库
Dim b() As Byte
ReDim b(FileLen(Text1.Text))
Dim ch As Long
ch = FreeFile
Open Text1.Text For Binary As #ch
    Get #ch, , b
Close #ch
Dim sql As String
Dim rs As ADODB.Recordset
sql = "select count(*) from images where imageName='" & CommonDialog1.FileTitle & "'"
Set rs = con.Execute(sql)
Dim rsw As New ADODB.Recordset
If (rs.Fields(0).Value >= 1) Then
    sql = "select * from images where  imageName='" & CommonDialog1.FileTitle & "'"
    rsw.Open sql, con, adOpenDynamic, adLockPessimistic
Else
    rsw.Open "images", con, adOpenDynamic, adLockPessimistic
    rsw.AddNew
End If
    rsw.Fields(0).Value = CommonDialog1.FileTitle
    rsw.Fields(1).Value = b
    rsw.Update
    rsw.Close
    Call getData
    MsgBox "写入成功!!!!"
End Sub
Private Sub Form_Load()
con.ConnectionString = "driver={sql server};server=localhost;database=w03;pwd=;uid=sa"
con.Open
Call getData
End Sub
Private Sub getData()
  Dim sql As String
  sql = "select imageName from images"
  Dim rs As ADODB.Recordset
  Set rs = con.Execute(sql)
  Combo1.Clear
  While (Not rs.EOF)
        Combo1.AddItem rs.Fields(0).Value
        rs.MoveNext
  Wend
  rs.Close
End Sub
请问红色代码部份是什么意思呢?谢谢!



 
											





 
	    

 
	



