Re: Streaming out image field data

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Uri Dimant (urid_at_iscar.co.il)
Date: 11/04/04


Date: Thu, 4 Nov 2004 10:09:42 +0200

Dallara
If I rememmber ,Dan Guzman has a great example about how to insert an image
by VB.NET (Search on Google)

Dim ADOCmd As New ADODB.Command
   Dim ADOprm As New ADODB.Parameter
   Dim ADOcon As ADODB.Connection
   Dim intFile As Integer
   Dim ImgBuff() As Byte
   Dim ImgLen As Long

   Set ADOcon = New ADODB.Connection
   With ADOcon
       .Provider = "MSDASQL"
       .CursorLocation = adUseClient
       .ConnectionString = "driver=
           {SQL Server};server=(local);uid=<username>;pwd=<strong
password>;database=pubs"
       .Open
   End With

   'Change this to the path of a GIF file you want to use for testing.
   IMG_FILE_GIF = "E:\Graphics\GIF\Image.gif"

   'Read/Store GIF file in ByteArray
    intFile = FreeFile
    Open IMG_FILE_GIF For Binary As #intFile
    ImgLen = LOF(intFile)
    ReDim ImgBuff(ImgLen) As Byte
    Get #intFile, , ImgBuff()
    Close #intFile

    Set ADOCmd.ActiveConnection = ADOcon
    ADOCmd.CommandType = adCmdStoredProc
    ADOCmd.CommandText = "uspInsertBLOB"

    Set ADOprm = ADOCmd.CreateParameter(, adChar, adParamInput, 1, "1")
    ADOCmd.Parameters.Append ADOprm

   'The datatype must be specified as adLongVarBinary

   'For the code to function correctly comment this line.

    Set ADOprm = ADOCmd.CreateParameter(, adLongVarBinary, _
          adParamInput, ImgLen)

    'Uncomment this line.
    'Set ADOprm = ADOCmd.CreateParameter(, adLongVarBinary, _
          adParamInput, (ImgLen + 1))
    ADOCmd.Parameters.Append ADOprm

   'Set the Value of the parameter with the AppendChunk method.

    ADOprm.AppendChunk ImgBuff()

   'The preceding example assumes you are using a small image file.
   'See the article reference in the REFERENCES section for handling a
   'large image file.

    ADOCmd.Execute

    Set ADOCmd = Nothing
    Set ADOprm = Nothing

"Dallara" <someone@microsoft.com> wrote in message
news:%239BqTAkwEHA.2908@tk2msftngp13.phx.gbl...
> Is there anyway to stream out BLOBs from SQL Server? Thorough the ADO.NET
> for instance.
>
>



Relevant Pages

  • Re: Image Data
    ... Dim ADOprm As New ADODB.Parameter ... Dim ADOcon As ADODB.Connection ... > I have an app that displays records containing Equipment Pictures. ...
    (microsoft.public.sqlserver.programming)
  • Re: Accessing a linked file in a Word document using VBA
    ... defintiion in the header Gallery. ... Dim Pwd As String ' String variable to hold passwords for protected documents ... Dim pState As Boolean ' Document protection state flag ... > update the source image file and the new image would appear ...
    (microsoft.public.word.vba.general)
  • Re: Accessing a linked file in a Word document using VBA
    ... I have tried the macro you listed - but it does not prompt. ... defintiion in the header Gallery. ... Dim Pwd As String ' String variable to hold passwords for protected documents ... update the source image file and the new image would appear ...
    (microsoft.public.word.vba.general)
  • Re: Accessing a linked file in a Word document using VBA
    ... Dim Pwd As String ' String variable to hold passwords for protected documents ... Dim pState As Boolean ' Document protection state flag ... Place the code in your document's template, then activate the document to be updated and run the macro 'ChangePicLinks'. ... update the source image file and the new image would appear ...
    (microsoft.public.word.vba.general)
  • Re: error in code
    ... Dim rsNew As DAO.Recordset ... Dim intFile As Integer ... Dim intEqualSign As Integer ... Dim strAfter As String ...
    (microsoft.public.access.modulesdaovba)