我试过bmp,jpg,jpeg,gif,可以的。其他应该同理的,数据库字段属性为image,二进制都可以存的

解决方案 »

  1.   

    但是我这里的VB控件显示不出来IMAGE BINTARYD的,再说SQL SEVER 里能存图片的数据类型不就只有BINTARY 和IMAGE 两种吗?
      

  2.   


     Const BLOCKSIZE = 4096  
          
        Public Sub SaveToDB(ByRef Fld As ADODB.Field, DiskFile As String, _  
         Optional ByRef FldDesc As ADODB.Field)  
          
         Dim strData As String '用 于 处 理 Text字 段  
         Dim byteData() As Byte '用 于 处 理 Image字 段  
         Dim NumBlocks As Long  
         Dim FileLength As Long  
         Dim LeftOver As Long  
         Dim SourceFile As Long  
         Dim I As Long  
          
         SourceFile = FreeFile  
         Open DiskFile For Binary Access Read As SourceFile  
         FileLength = LOF(SourceFile)  
         If FileLength = 0 Then  
         Close SourceFile  
         MsgBox DiskFile & " 无 内 容 或 不 存 在 !"  
         Else  
         NumBlocks = FileLength \ BLOCKSIZE  
         LeftOver = FileLength Mod BLOCKSIZE  
         Fld.Value = Null  
         Select Case Fld.Type  
         Case adLongVarBinary 'Image 字 段  
         ReDim byteData(NumBlocks)  
         For I = 1 To NumBlocks  
         Get SourceFile, , byteData()  
         Fld.AppendChunk byteData()  
         Next I  
         ReDim byteData(LeftOver)  
         Get SourceFile, , byteData()  
         Fld.AppendChunk byteData()  
         Case adLongVarChar 'Text 字 段  
         strData = String(BLOCKSIZE, 32)  
         For I = 1 To NumBlocks  
         Get SourceFile, , strData  
         Fld.AppendChunk strData  
         Next I  
         strData = String(LeftOver, 32)  
         Fld.AppendChunk strData  
         End Select  
         Close SourceFile  
         If Not IsMissing(FldDesc) Then FldDesc.Value = Mid(DiskFile, PosA(DiskFile, "\") + 1)  
         End If  
        End Sub