SQL Server Performance

Saving Blob from Power Builder to SQL Server 2000

Discussion in 'General Developer Questions' started by dasbkp, Feb 20, 2006.

  1. dasbkp New Member

    I 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.
    FileClose(fh)
    END IF
    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
    dasbkp@yahoo.com
  2. Tahsin New Member

    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
    go
  3. dasbkp New Member

    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



  4. Madhivanan Moderator

  5. dasbkp New Member

    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.

Share This Page