Save Access Report as PDF/Binary

前端 未结 2 1240
忘了有多久
忘了有多久 2021-01-20 18:56

I am using Access 2007 (VBA - adp) front end with a SQL Server 2005 Backend. I have a report that I want to save a copy as a PDF as a binary file in the SQL Server.

相关标签:
2条回答
  • 2021-01-20 19:12

    There are different opinions if it's a good idea to store binary files in database tables or not. Some say it's ok, some prefer to save the files in the file system and only store the location of the file in the DB.

    I'm one of those who say it's ok - we have a >440 GB SQL Server 2005 database in which we store PDF files and images. It runs perfectly well and we don't have any problems with it (for example with speed...that's usually one main argument of the "file system" people).

    If you don't know how to save the files in the database, google "GetChunk" and "AppendChunk" and you will find examples like this one.

    Concerning database design:
    It's best if you make two tables: one only with an ID and the blob field (where the PDF files are stored in) and one with the ID and additional fields for filtering.
    If you do it this way, all the searching and filtering will happen on the small table, and only when you know the ID of the file you want to load, you hit the big table exactly one time and load the file.
    We do it like this and like I said before - the database contains nearly 450 GB of files, and we have no speed problems at all.

    0 讨论(0)
  • 2021-01-20 19:33

    The easiest way to do this is to save the report out to disk as a PDF (if you don't know how to do that, I recommend this thread on the MSDN forums). After that, you'll need to use ADO to import the file using OLE embedding into a binary type of field. I'm rusty on that, so I can't give specifics, but Google searching has been iffy so far.

    I'd recommend against storing PDF files in Access databases -- Jet has a strict limit to database size, and PDFs can fill up that limit if you're not careful. A better bet is to use OLE linking to the file, and retrieving it from disk each time the user asks for it.

    The last bit of advice is to use an ObjectFrame to show the PDF on disk, which MSDN covers very well here.

    0 讨论(0)
提交回复
热议问题