I know how to do it using DAO, but it should be similar using ADO. In your database, create a field called something like WaveData, with the dbLongBinary type (or OLE_OBJECT as it's called in Access I think). Then you can just read and write the WAV file like this: (DAO sample)
Hope this helps...Code:Dim WS As DAO.Workspace Dim DB As DAO.Database Dim RS As DAO.Recordset Dim bData() As Byte Dim iFree As Integer ' Open the database, And the 'Waves' table... Set WS = DBEngine.Workspaces(0) Set DB = WS.OpenDatabase("c:\wav.mdb") Set RS = DB.OpenRecordset("Waves") ' Read the WAV file iFree = FreeFile() Open "c:\sample.wav" For Binary Access Read As #iFree ReDim bData(LOF(iFree)) Get #iFree, , bData() Close #iFree ' Add it To the database RS.AddNew RS("WaveData") = bData() RS.Update ' Now To read it again, move To the first item (To keep it simple) RS.MoveFirst ' Size the Byte array And read it from the DB ReDim bData(RS("WaveData").FieldSize) bData() = RS("WaveData") ' Now you can Write it To a file again, like this: iFree = FreeFile() Open "c:\fromdb.wav" For Binary Access Write Lock Read Write As #iFree Put #iFree, , bData() Close #iFree ' Close the DB Set RS = Nothing Set DB = Nothing Set WS = Nothing




Reply With Quote