Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to store an image in a field with a query? 1

Status
Not open for further replies.

WomanPro

Programmer
Nov 1, 2012
180
GR
hello everybody,
I have a table in a database and a field of it need to be an image
how can I store an image with a query?

I have tried that
INSERT INTO Tracks ('C:\Documents and Settings\Neraidopetalouda\Τα έγγραφά μου\Η μουσική μου\moby.jpg') where TrackTitle='Mistake')

without effect? any help please?
 
I don't think you can do this with a query unless there is some function you can right to return the blob for the file and use it in your query.

It looks like you want to put the same picture in for a number of records. First I would suggest that rather than doing this, you consider storing the images separate and having a foreign key to retrieve images in your table.

That said if you really want to do this, as a one off, I would make a table that has one record, the image you want to update records with. Secondly I would use the field in this table to update the destination field in the target table. In this way you can avoid updating a bunch of records manually.

There are also examples around the net to load data in using a recordset and filestream.
 
no effect :( I have tried everythig, to be clear my talbe stores a TrackId, TrackName, Image
it's very important to have an image for each record. I don't believe that I can't do something :(
 
So is your opinion just to store only the filepaths of each image?
 
Generally people only store filepaths either as text or hyperlinks unless there is some need to do otherwise. The only time I stored this type of data in a database it was SQL server and I did that to store the support files that needed to be downloaded to the client and in the organization I was at this was easier than trying to get permissions set. In my case it was office docs but the same principle. In this case I had to read a filestream into the SQL connected ADO recordset... I don't have that code now but I believe I found an MS sample that I modifed to do it.

Storing long binary data (files) in a database is genrerally problematic. I had my several files(maybe 3 dozen) working in SQL Server and Access frontend without incident. Most certainly storing paths is better for your database performance.
 
maybe yes!!! I used a picture box and with imagelocation I loaded the image.
I need it in a listview, I will see how I will do that... I am using vb.net 2005 so ado, is pretty oldier technology. I have posted to vb.net 2005 for further assistance. Thank you much in advanced.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top