Saving Image in MS SQL 2000 Database
I want to save Image file in Database .. Data Type for i have used is image.
how would i save it in a database...... and then retrive it on the form back.
Also how can i then display it in Crystal report 8. one idea i have is OLE Object but not clear about it that how to use it..
:wave:
Re: Saving Image in MS SQL 2000 Database
For saving it, see Beacon's tutorial in the database section.
Re: Saving Image in MS SQL 2000 Database
To store & save binary data (images or other files like that) use the image data type in the DB. Them look into the GetChunk and AppendChunk methods of the recordset object.
Tg
Re: Saving Image in MS SQL 2000 Database
i think it will be more easier to save the path rather than save the image it self.so the type data in database is just text.( Just find this code today :D )
this code need dirlistbox and filelistbox
VB Code:
Private Sub Form_Load()
File1.path = App.path & "\images\" 'save all image in one folder named images and retrieve it
End Sub
Private Sub OKButton_Click()
path = File1.path + "\" + File1.FileName
picture1.Picture = LoadPicture(path)
End Sub
hope this can help
Re: Saving Image in MS SQL 2000 Database
Quote:
Originally Posted by little_mouse
i think it will be more easier to save the path rather than save the image it self.so the type data in database is just text.( Just find this code today :D )
this code need dirlistbox and filelistbox
VB Code:
Private Sub Form_Load()
File1.path = App.path & "\images\" 'save all image in one folder named images and retrieve it
End Sub
Private Sub OKButton_Click()
path = File1.path + "\" + File1.FileName
picture1.Picture = LoadPicture(path)
End Sub
hope this can help
The only issue with this (and it can be a big one) is if/when the images get moved.
Re: Saving Image in MS SQL 2000 Database
yah,so that must put the image on folder images :p.
is it comsume more space if saving the image on database?
Re: Saving Image in MS SQL 2000 Database
Quote:
Originally Posted by little_mouse
yah,so that must put the image on folder images :p.
is it comsume more space if saving the image on database?
A BLOB will always take more space than a string. There are a number of factors that would have to be considered before deciding on a direction, but probably the most important ones would be:
How many images will be stored over a six month period? Over a year? More than a year?
How long will the database be required to keep an image once it is stored?
How much storage space do we have? What is the process/impact for getting more if we need it?
Re: Saving Image in MS SQL 2000 Database
We use this method to distribute reports to our customers. When we were building the infrastructure, we knew that server information would vary from customer to customer, and we wanted the ability to limit who could make changes to the reports. So we created a table with an image field and we "stuff" our reports into it. We can then use that ReportID and a ScreenID (from another table) to link what reports are available from what screens.
To deploy a report, we stuff it into our copy of their database (there's a spot in the admin section where this can be done) and then we script the binary information into a SQL Script. The customer then takes this "bin" script and runs it on their server. And viola, they then have the report.
In your case, what happens when Joe Schmoe comes along and says, hey what are these doing here? and hits the delete button.... bad juju.
I know a lot of people advocate just storing the path in the DB, but that can lead to problems down the road (not that it will, just that it can.)
So you realy need to ask yourself what the risk is, and what to do if/should it happen, how to recover and what makes sense.
Tg
Re: Saving Image in MS SQL 2000 Database
We do much the same thing in my shop. We market RiskManagment software, and we have provided our customers with the ability to store police reports, physicians diagnostic reports, claims adjustment reports, legal depositions, etc, etc as well as things like photos taken at accident scenes. Our thing works pretty much the way Tg explained.
Physically storing these files on a server, and just storing the paths could potentially create all sorts of problems, not the least of which is that most, if not all of these types of documents are confidential. If they were just sitting out there, anyone hacking into their network could grab them. (This is above and beyond the possibility of them being moved or deleted.)
Up front, however, we tell our customers that this is going to require some hardware investment on their part as these will increase the storage requirements of their database.
Re: Saving Image in MS SQL 2000 Database
Quote:
Originally Posted by vbcoder2
I want to save Image file in Database .. Data Type for i have used is image.
how would i save it in a database...... and then retrive it on the form back.
Also how can i then display it in Crystal report 8. one idea i have is OLE Object but not clear about it that how to use it..
:wave:
Search through my posts: I have two samples - one to store a file (any file) and one to retrieve it.