SQL Server Performance Forum – Threads Archive
Saving Blob from Power Builder to SQL Server 2000I need to save an image file stored in a Blob variable into a binary column "PHOTO" in table Employee and when i need, retrieve the same to display on the Form. For this i have used the following PB code, which opens a dialog to select a BMP file and converts the selected file into Blob. integer fh, ret
string txtname, named
string defext = "BMP"
string Filter = "bitmap Files (*.bmp), *.bmp"
//Below line opens a dialog to select the file.
ret = GetFileOpenName("Attach Employee Photo", txtname,named, defext, filter)
//on success ret will be 1
IF ret = 1 THEN
fh = FileOpen(txtname, StreamMode!)
IF fh <> -1 THEN //if success to open the file.
FileReadEx(fh, Emppic) // Reads the file into Blob "Emppic.
END IF The above code working fine & stores the image into the Blob. Now i need the above Emppic Blob data to store into column photo(binary) in table Employee. Also, i need to retrieve the same to display in front end Form. Please, suggest me the SQL & column data type, which will best fit here. Thanks in advance… B.K. Das
You will need to add an IMAGE type column to the Employee table. The alter statement will look something like this if you are adding it in Query Analyzer: ALTER TABLE EMPLOYEE
ADD photo IMAGE NULL
Thanks a lot. Thanks for ur quick response. Perhaps myself not clearly explain what i need in above. Half of my query you have solved. Now i need the SQL statement( i.e. Transact SQL) that will help me to save the Blob into the table during adding a record or updating a record. Also, the SELECT statement that will help me to retrieve the image field value to a Blob variable. B.K. Das
How about storing only the physical path of the images in the table and save images in the Server directory so that you will be able to display images in Front End using File system object? Also read this
http://www.microsoft.com/technet/prodtechnol/sql/2000/reskit/part3/c1161.mspx Madhivanan Failing to plan is Planning to fail
I think your idea is best suitable and also decreases the database size and gives faster response. But, the path what i will use should not be unsecured. How it can accessed with a great security ? The suggested link will help me to try & find some way to save the image to the database.