Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Re: using vb with ado 2.5 to insert a wav file into sql server


Message #1 by "Douglas" <doug.poate@t...> on Thu, 5 Oct 2000 17:18:48 +0100
Use the Stream object to save any file into a SQL Server database.

TO GET A FILE OUT OF A DATABASE:

(this assumes you have a connection and recordset already created.  The
recordset must contain the BLOB field)
Dim mstream as ADODB.Stream

SET mstream = New ADODB.Stream

mstream.Type = adTypeBinary
mstream.Open
mstream.Write myRecordset.Fields("BLOBField").Value
mstream.SaveToFile "<path for file>", asSaveCreateOverWrite





TO PUT A FILE INTO A DATABASE:
(this, again, assumes you have a connection and recordset already created.
The recordset must contain the BLOB field)
SET mstream = New ADODB.Stream

mstream.Type = adTypeBinary
mstream.Open
mstream.LoadFromFile "<path for file>", asSaveCreateOverWrite
myRecordset.Fields("BLOBField").Value = mstream.Read
myRecordset.Update



------------------------------------------------------
Christopher Tacke, MCSD
Associate
Rubicon Technologies
(xxx) xxx-xxxx  Ext. 319



  Return to Index