Function | FieldToFile(ByVal fld As ADODB.Field, ByVal FName As String, Optional FieldSize As Long = -1, Optional Threshold As Long = 1048576) As Boolean |
---|---|
fld: Datenbankfeld FName:Name der Datei, in der Datenbankfeldinhalt gespeichert werden soll OPTIONAL FieldSize: Feldgröße OPTIONAL Treshold: Grenzwert Rückgabewert: = True, wenn der Datenbankinhalt in der Datei gespeichert werden konnte; sonst = False Public Function FieldToFile(ByVal fld As ADODB.Field, ByVal FName As String, Optional FieldSize As Long = -1, Optional Threshold As Long = 1048576) As Boolean Dim f As Long, bData() As Byte, sData As String On Error GoTo ErrorHandler FieldToFile = True m_oUtil.Kill FName f = FreeFile Open FName For Binary As #f Select Case fld.Type Case adLongVarBinary If FieldSize = -1 Then ' blob field is of unknown size FieldToFile = WriteFromUnsizedBinary(f, fld) Else ' blob field is of known size If FieldSize > Threshold Then ' very large actual data FieldToFile = WriteFromBinary(f, fld, FieldSize) Else ' smallish actual data bData = fld.value Put #f, , bData ' PUT tacks on overhead if use fld.Value End If End If Case adLongVarChar If FieldSize = -1 Then WriteFromUnsizedText f, fld Else If FieldSize > Threshold Then FieldToFile = WriteFromText(f, fld, FieldSize) Else sData = fld.value Put #f, , sData ' PUT tacks on overhead if use fld.Value End If End If End Select Close #f Exit Function ErrorHandler: FieldToFile = False Close #f Err.Raise Err.Number, Err.Source, Err.Description End Function |