Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: RE: Saving Picture in Access DB using VB 6.0


Message #1 by "Paul Fabbroni" <Paul.Fabbroni@s...> on Thu, 28 Jun 2001 19:47:51
Hello,
Should i take the DATATYPE as OLE or some thing else
I'm asking you this silly question because I never used such things

Waiting for your reply

  ----- Original Message -----
  From: Chris Tacke
  To: professional vb
  Sent: Thursday, June 28, 2001 12:18 PM
  Subject: [pro_vb] RE: Saving Picture in Access DB using VB 6.0


  GetChunk and AppendChuck are ugly and obsolete.  If you're using ADO 
2.5 or
  better, use the Stream object instead:


  <VBCODE>
  Public Sub SaveFileToField(FieldName As String, FileName As String,
  ConnectionString As String)
      Dim cn As ADODB.Connection
      Dim rs As ADODB.Recordset
      Dim mstream As ADODB.Stream

      Set cn =3D New Connection
      cn.open ConnectionString

      Set mstream =3D New Stream
      mstream.Type =3D adTypeBinary
      mstream.open

      mstream.LoadFromFile FileName
      rs.fields(FieldName).Value =3D mstream.read
      rs.Update

      rs.Close
      cn.Close
      Set rs =3D Nothing
      Set cn =3D Nothing
  End Sub

  Public Sub SaveFieldToFile(FieldName As String, FileName As String,
  ConnectionString As String)
      Dim cn As ADODB.Connection
      Dim rs As ADODB.Recordset
      Dim mstream As ADODB.Stream

      Set cn =3D New Connection
      cn.open ConnectionString

      Set mstream =3D New Stream
      mstream.Type =3D adTypeBinary
      mstream.open

      mstream.write rs.fields(FieldName).Value
      mstream.SaveToFile FileName, adSaveCreateOverwrite

      rs.Close
      cn.Close
      Set rs =3D Nothing
      Set cn =3D Nothing
  End Sub

  </VBCODE>


  ----------------------------
  Christopher Tacke, MCSD
  President, Innovative Decision Support Systems
  innovativedss.com

  > -----Original Message-----
  > From: Paul Fabbroni [mailto:Paul.Fabbroni@s...]
  > Sent: Thursday, June 28, 2001 7:48 PM
  > To: professional vb
  > Subject: [pro_vb] RE: Saving Picture in Access DB using VB 6.0
  >
  >
  > I hope yo uread this cuz this is from a long time ago but on the
  > following
  > line:
  >
  > StrBuffer() =3D F.GetChunk(LngChunkSize)
  >
  > I get the following error...  "The operation requested by the 
application
  > is not allowed in this context" message 3219.  It might be because 
I'm
  > passing it a recordset.field object, I read something about it not 
liking
  > recordets... any thoughts?


  Return to Index