Working with pictures in MS Access and SQL Server - sql

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"

Related

Send chart with SQL Server without ssrs

I'm trying to send an email through SQL Server using sp_send_dbmail. I wanted to add a pie chart to it, I tried using google charts, however my SQL Server doesn't allow access to the internet so it can't be done, also there is no SSRS installed on the server and I doubt I can install it (work server).
My table is quite simple.
My question: is there any way to send a chart on the email from a table to recap the results?
Thanks a lot for any help :)
I don't believe this is possible. You can add attachments with "sp_send_dbmail" but it isn't nearly sophisticated enough to send a pie chart. Here is the link to more information about "sp_send_dbmail."
I think your only viable option here is to have a document with the pie chart built ahead of time. If you want the chart to be built from table data it will require a standalone application in some language (.net, java, etc.) and from there you can save the file to a local directory. Use the "#file_attachments" property from "sp_send_dbmail" to get the attachment.

How can I display an Image from MS SQL Server on to a MS Access form? [duplicate]

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"

Store PDF or image in SQL Server database with navicat or sql management studio

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 to view and change data of a .mdf file using MS Access?

Background: I have an .mdf database containing some numeric values that I need to change (specifically, scale and offset values for sensors). The database was created by a Visual Basic program that controls some lab equipment and stores pertinent data in the .mdf file. Please excuse my rudimentary knowledge of the topic; I'm a complete novice when it comes to SQL Server and VB.
After searching through many posts, I understand that to open the .mdf file, you must "attach" it in Microsoft Server Management Studio (I'm using that with SQL Server 2005), which I have successfully done.
Problem: It seems that this only allows me to view and modify the structure of the database, ie. tables, columns, data types etc., rather than the values of the database itself.
Is there a way to do this manually, like how you can edit the field data of .mdb files in MS Access? Again, sorry for my limited knowledge on the topic. I'll gladly provide extra details where needed.
You mention you want to use access. That can be done. Your database is up and running after attaching it.
In Access you can simply create an ODBC connection in access and use Access to edit/modify your data as much as you want. you can also create queries.
It is in the menu item "external data" [I'm guessing because I use a dutch version]. You select to create a "linked table", choose your server and you are done.
Right-click on the table you want to modify in SSMS and select "Edit Top 200 Rows".
If you have more than 200 rows to edit, you can connect to the SQL Server database with either Access or Excel.
Here are the instructions for Access:
http://office.microsoft.com/en-us/access-help/connect-an-access-project-to-a-microsoft-sql-server-database-adp-HP005274586.aspx

Accessing Content from MDF after attached to SQL

I am using WSS 3.0 and trying to restore a mdf. I attached the database in SQL Management Studio, created a new web application, and associated the database to it. When I go into Central Administration-> Application Management -> Content Databases I see the WSS_Content and it says Sites: 2. One of the sites looks more similar to the other. I was able to log into the Sharepoint web app that has the db attached to it, and while it gives me the basic structure of the backed up site, the content of lists is blank, that was the data I was really after (Announcements, tasks, etc exist as lists but are empty). How do I get access to this?
Kindly remove your old database and make newly added database as a default/only database for your webapplication
I'd link to the the data from SQL Server into an Access database.. and then use MS Access to write these values back into sharepoint.
I've written a LOT of data to sharepoint using MS Access.. and I love the functionality.
the data is in SQL server.. but it's got different guids, or it's not wired up from what I'd assume.
You have the data posted to the SQL Server instance.. I'd just link to it in MS Access, write a couple of queries.. recreate a couple of lists.. and then push it from queries based on Access linked tables (to sql server).. and then jam it into Access linked tables (to sharepoint).
Open Access. right-click link basically. times two. and write a couple of queries.
If it was me, and it was just a couple of lists, I'd do this in a couple of minutes I swear.