I have manage to write images on an sql server 2008
But i see that in the image record writing the same bytes in all of the images
And also it creates on the remote disk under a special catalogue a file which finally is the image
Is there anybody which can explain me the flow chart of writing an image in sql server?
What is contained in the image record?
Here are a couple of tutorials on saving image data in a FILESTREAM column in SQL Server 2008:
http://blogs.msdn.com/rdoherty/archive/2007/10/12/getting-traction-with-sql-server-2008-filestream.aspx
http://lennilobel.wordpress.com/2009/09/22/sql-server-2008-filestream-part-1-of-3-introducing-filestream/
http://lennilobel.wordpress.com/2009/10/06/sql-server-2008-filestream-part-2-of-3-enabling-and-using-filestream/
http://lennilobel.wordpress.com/2009/10/20/sql-server-2008-filestream-part-3-of-3-using-the-opensqlfilestream-api/
Related
I am working in SQL Server 2008 R2.
I am currently generating PDF reports by building the pdf as plaintext (based on this: http://www.sqlservercentral.com/articles/Miscellaneous/creatingapdffromastoredprocedure/1104/ )
It builds the body in plaintext then saves it to a folder using sp_OACreate with the .pdf extension. It is actually faster than SSRS in this case; we are generating 5k-100k pdfs (historical transaction data for our customers' customers)
I then have to load these files into an image column so the clients can access their report through the software.
Is there a way to generate the file and convert it to an image without writing it to the disk and then reloading it?
I cannot change the software, the file must be presented to the client when they click the button in the interface.
I cannot change the database. I have these files saved as image datatypes. I cannot change this to any other data type. The files are all less than 20k in size.
I cannot implement filestream due to PCI Compliance security reasons.
For SQL Server you can program stored procedure on .NET language (C#, VB...) Inside .NET assembly write code for generating PDF reports. Then you only have to execute this stored procedure and save it result to database table.
How exactly does one go about:
getting images/pictures into a SQL database
viewing pictures from a SQL database using a MS Access form?
I currently use an ODBC link between the two databases with no problems at all, but I'm struggling to understand what I need to do to achieve what I'm trying to achieve.
I have already tried Google, but haven't yet come across the right information.
Getting pictures in and out of an SQL Server database:
You need the GetChunk and AppendChunk functions for that.
Here's a tutorial: How To Read and Write BLOBs Using GetChunk and AppendChunk.
This tutorial is a bit dated, but as far as I know this is still the best way to load/save pictures in a database from VBA.
Note that in SQL Server, you should use a varbinary(max) field (instead of the image suggested in the tutorial) to store the pictures.
Displaying the pictures in an MS Access form:
You can't display a picture directly from the database. You have to load it from the database (see above), store it in a temp folder and display it from there.
To get Windows' temp folder, use Environ("temp") or the GetTempPath API function.
To display the picture you can either set it as the background of the form:
Me.Picture = "c:\...\temp\picture.jpg"
...or use a image control:
Me.NameOfImageControl.Picture = "c:\...\temp\picture.jpg"
I have an Access 2010 odbc front end with a SQL Server 2012 back end. My images (.bmp) are stored as Varbinary(Max). When I insert an image using my bound object frame in an Access form, the image displays on the form and report perfectly. I had a large number of pictures to bring into SQL so I used the following code in SQL Server Management Studio:
UPDATE dbo.Photos_Observations
SET [Photo] = (SELECT BulkColumn
FROM Openrowset( Bulk '\\serverIP\servername\020.BMP', Single_Blob) as MyImage)
WHERE PhotoTableID =391
This worked well and all 600+ pictures are now in SQL Server. BUT the ones I added this way don't show up on my Access form or report. When I click on the Bound Object Frame I get Error number 502753 "A problem occurred while Microsoft Access was communicating with the OLE server or ActiveX control."
Why does it work one way and not the other? How can I get the images to display?
It looks like you bulk-inserted the raw binary image data directly from the BMP file into the VARBINARY column using T-SQL. Therefore, those images don't have the "OLE wrapper" that is added when an image is inserted via a Bound Object Frame on an Access form.
See the my answer to a related question for a way to automate the insertion of "OLE wrapped" images. (It's a bit clunky, but still better than doing it all by hand.)
Another approach is to use an Image control instead of a Bound Object Frame, and store the images as raw binary data instead of as "OLE wrapped" objects. That is increasingly becoming the preferred way to handle images being stored in the database itself. (OLE objects can be a nuisance, especially when working with applications other than Access.)
This one's going back to the basics but I haven't been able to find a simple explanation anywhere. I just started working with databases and I'm using a SQL Server database managed mostly with navicat (but I have SQL Server Management Studio as well) and I need to store a PDF or image in the database.
I'm using Entity Framework to interface the database with the C# app I am building. A simple explanation assuming little knowledge of database management would be much appreciated.
Thanks for the help.
The database size will grow exponentially if you start storing images and PDF's.
A better approach would probably be to store the path of the file in the database and then load the item by referencing the proper path.
EDIT:
It's going to depend on the file structure of your application really. A simple version of retrieving a PDF could be the following:
Example Path:
/PDF/username.PDF
You store the path of the PDF in the DB, maybe under pdfPath. Then when you retrieve the path from the database direct the user to the correct link using the path you got from the query.
How exactly does one go about:
getting images/pictures into a SQL database
viewing pictures from a SQL database using a MS Access form?
I currently use an ODBC link between the two databases with no problems at all, but I'm struggling to understand what I need to do to achieve what I'm trying to achieve.
I have already tried Google, but haven't yet come across the right information.
Getting pictures in and out of an SQL Server database:
You need the GetChunk and AppendChunk functions for that.
Here's a tutorial: How To Read and Write BLOBs Using GetChunk and AppendChunk.
This tutorial is a bit dated, but as far as I know this is still the best way to load/save pictures in a database from VBA.
Note that in SQL Server, you should use a varbinary(max) field (instead of the image suggested in the tutorial) to store the pictures.
Displaying the pictures in an MS Access form:
You can't display a picture directly from the database. You have to load it from the database (see above), store it in a temp folder and display it from there.
To get Windows' temp folder, use Environ("temp") or the GetTempPath API function.
To display the picture you can either set it as the background of the form:
Me.Picture = "c:\...\temp\picture.jpg"
...or use a image control:
Me.NameOfImageControl.Picture = "c:\...\temp\picture.jpg"