How to use ADO stream method

masoud_sedighy

Registered User.
Local time
Today, 09:34
Joined
Dec 10, 2011
Messages
132
I would like by using ms access (FE) read pdf files from shared folder and then write this pdf file in varbinary (max) column of sql server table. And also reading this pdf file by accesing to this varbinary (max) column.
I found a almost similar question in the net that was using ADO stream method.


http://answers.microsoft.com/en-us/office/forum/office_2010-access/how-can-i-extract-ole-object-audio-files-from-an/fbffe173-f56b-4e96-bb4f-0e346886d2a2?db=5

I would like to know can i use ADO stream method for saving and retrieving pdf files from sql server by using ms access (FE)?
 
Just attach the table in the FE.
Then open the PDF by calling this sub.
Paste this code into a module and it will open any file in its native app.
Feed it the pdf path and it will open in acrobat....
Usage: opennativeapp txtBox

Code:
'Attribute VB_Name = "modNativeApp"
'Option Compare Database
Option Explicit

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long

Private Declare Function GetDesktopWindow Lib "user32" () As Long
Const SW_SHOWNORMAL = 1
Const SE_ERR_FNF = 2&
Const SE_ERR_PNF = 3&
Const SE_ERR_ACCESSDENIED = 5&
Const SE_ERR_OOM = 8&
Const SE_ERR_DLLNOTFOUND = 32&
Const SE_ERR_SHARE = 26&
Const SE_ERR_ASSOCINCOMPLETE = 27&
Const SE_ERR_DDETIMEOUT = 28&
Const SE_ERR_DDEFAIL = 29&
Const SE_ERR_DDEBUSY = 30&
Const SE_ERR_NOASSOC = 31&
Const ERROR_BAD_FORMAT = 11&


Public Sub OpenNativeApp(ByVal psDocName As String)
Dim r As Long, msg As String

r = StartDoc(psDocName)
If r <= 32 Then
    'There was an error
    Select Case r
        Case SE_ERR_FNF
            msg = "File not found"
        Case SE_ERR_PNF
            msg = "Path not found"
        Case SE_ERR_ACCESSDENIED
            msg = "Access denied"
        Case SE_ERR_OOM
            msg = "Out of memory"
        Case SE_ERR_DLLNOTFOUND
            msg = "DLL not found"
        Case SE_ERR_SHARE
            msg = "A sharing violation occurred"
        Case SE_ERR_ASSOCINCOMPLETE
            msg = "Incomplete or invalid file association"
        Case SE_ERR_DDETIMEOUT
            msg = "DDE Time out"
        Case SE_ERR_DDEFAIL
            msg = "DDE transaction failed"
        Case SE_ERR_DDEBUSY
            msg = "DDE busy"
        Case SE_ERR_NOASSOC
            msg = "No association for file extension"
        Case ERROR_BAD_FORMAT
            msg = "Invalid EXE file or error in EXE image"
        Case Else
            msg = "Unknown error"
    End Select
'    MsgBox msg
End If
End Sub
 
There some code from this site that I used to copy an image file to a OLE field and back to a file. If the varbinary type shows up at an OLE object in Access it might get you started.

How does the varbinary field show up in a linked table to a sql server table?
 

Users who are viewing this thread

Back
Top Bottom