ОК. Список составить удалось. Но он чето глючит с длинными русскими именами (пробелы там тоже есть). Просто далее хочу засунуть эти файлы в базу, но он вставляет в базу пустоту: Public Function SaveFileToDB(ByVal FileName As String, RS As Object, FieldName As String) As Boolean Dim iFileNum As Integer Dim lFileLength As Long Dim abBytes() As Byte Dim iCtr As Integer On Error GoTo ErrorHandler If FileName = "" Then Exit Function If Not TypeOf RS Is ADODB.Recordset Then Exit Function 'ñ÷èòàòü ôàéë â ìàññèâ iFileNum = FreeFile Open FileName For Binary Access Read As #iFileNum lFileLength = LOF(iFileNum) ReDim abBytes(lFileLength) Get #iFileNum, , abBytes() 'ïîìåñòèòü ñîäåðæèìîå ìàññèâà â ÁÄ RS.Fields(FieldName).AppendChunk abBytes() Close #iFileNum SaveFileToDB = True ErrorHandler: End Function Public Function LoadFileFromDB(FileName As String, _ RS As Object, FieldName As String) As Boolean Dim iFileNum As Integer Dim lFileLength As Long Dim abBytes() As Byte Dim iCtr As Integer On Error GoTo ErrorHandler If Not TypeOf RS Is ADODB.Recordset Then Exit Function iFileNum = FreeFile Open FileName For Binary As #iFileNum lFileLength = LenB(RS(FieldName)) abBytes = RS(FieldName).GetChunk(lFileLength) Put #iFileNum, , abBytes() Close #iFileNum LoadFileFromDB = True ErrorHandler: End Function Private Sub Command1_Click() Dim sConn As String Dim oConn As New ADODB.Connection Dim oRs As New ADODB.Recordset sConn = "Provider=Microsoft.Jet.OLEDB.4.0ata Source=D:\Work\vb\propuck\photo\db.MDB;Persist Security Info=False" oConn.Open sConn oRs.Open "SELECT * FROM MYTABLE", oConn, adOpenKeyset, adLockOptimistic oRs.AddNew SaveFileToDB "С:\1.BMP", oRs, "MyFieldName" oRs.Update oRs.Close End Sub Где ошибка?
Ответить
|