How to store/display images with SQL Server 2000

Hi everybody, I'm totally new to ColdFusion, and creating a
sample project, where a user would enter in a person's info and
upload a picture of that person. I trying to get my app to save
that image to SQL Server database and then to display that pic.
Currently, it "seems" that I'm able to save to SQL server (my table
saves user info but all values in my photo column says
<binary>-I don't know if that is correct), but I can't seem
to get image and display it on my cf page. I have pasted portions
of my code below.
I've been hammering away at this but no luck, so Any comments
are very well appreciated, example code would be great!
Thank you so much,
noijet
# 1.) I have a 'User Info Entry' page that submits to page
#2:
<cfform...>
<input name="fileToUpload" id="fileToUpload" type="file"
size="64"/>
</cfform>
# 2.) This page does the actual saving, this doesn't output
any errors but am I saving the image to SQL server correctly? I
have no idea really how to save images to database, so please
advise or possibly provide example code. Afterwards, it goes to
page #3 to display confirmation page that data has been saved.
<cfif isDefined("Form.fileToUpload") and Form.fileToUpload
neq "">
<cfset uploadPath =
GetDirectoryFromPath(GetBaseTemplatePath()) & "uploads\">
<cfif not DirectoryExists(uploadPath)>
<cfdirectory action="create" directory="#uploadPath#">
</cfif>
<cffile action="upload" fileField="fileToUpload"
destination="#uploadPath#" nameConflict="overwrite">
<cfset imagefile= "uploads\\" & cffile.serverFile
& "'">
</cfif>
<cfquery name="qInsertPerson" dataSource="HRP">
Execute insertPerson
N'#Trim(FORM.sLastname)#',N'#Trim(FORM.sFirstname)#',N'#Trim(FORM.sMiddle)#',N'#Trim(FORM .sAlias)#',
'#imagefile#'
</cfquery>
<cflocation url = "savePersonResult.cfm" addToken =
"No">
#3.) This confirmation page displays last user entered and a
picture of the user. The user info retrieved from SQL server is
displaying correctly but the picture is not displaying(just a small
red 'x' box). The image calls another getPersonPhoto.cfm file to
display image.
<cfquery name="lastPerson" datasource="HRP">
Exec getLastRow
</cfquery>
<cfoutput query="lastPerson">
#firstName# #middle# #lastName# was added to our Persons
list. That Person has been given id: #id# <br>
Thank you for your assistance and cooperation.
<img src="getPersonPhoto.cfm?id=71" border="0" width="128"
height="180">
</cfoutput>
#4.) This is .cfm file that only displays image of person
<cfsetting enablecfoutputonly="Yes">
<cfsetting showdebugoutput="No">
<cfquery name="getBlob" datasource="HRP">
SELECT TOP 1 photo FROM Persons WHERE id = 71
</cfquery>
<cfheader name="content-disposition"
value="Inline;filename=ExamplePerson.jpg">
<cfcontent type="image/jpeg; charset=iso-8859-1">
<cfoutput>#tostring(tobinary(getBlob.photo))#</cfoutput>
Note: In my ColdFusion admin, I checked "Enable ... BLOB's"
and set Blob Buffer to 20000

Regarding doing the actual saving, here are some other things
to consider:
* a max on the image's file size
* check if it really is an image
* don't use nameconflict="overwrite". consider
nameconflict="MAKEUNIQUE"
* delete uploaded image on file system after insert into db
Also, on the cfm page that returns an image, try putting the
cfcontent tag and the cfoutput tag on one line.
<cfheader name="Content-Type" value="image/jpeg">
<cfcontent
type="image/jpeg"><cfoutput>#getBlob.photo#</cfoutput>
Good luck!

Similar Messages

  • How to store jpeg images in SQL server using NI database Connectivity Toolset. Can anyone please help me in this regard.

    Please tell how to store jpeg images in SQL Server using NI Database Connectivity Toolset.

    http://www.w3schools.com/sql/sql_datatypes.asp
    You setup a field as BLOB and store the binary of the picture there. Depending on the database it can be called differently as you can see in the link, in SQL server there's even a Image datatype.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • How to enter one image to sql server 2000 and then view it ...

    for example x="g:\12.jpg"

    You may check this tip:
    How to store/retrieve image to/from SQLServer
    http://www.java-tips.org/content/view/203/29/

  • How to store 999999999.00000000 in sql server through ssis package?

    I have a field with 999999999.00000000 value of datatype double ?
    How to store it in ms sql server 2005 db through ssis package ?
    give me details if I have to use derived columns and what to write over there.
    please write in details as I am new to SSIS.
    Thanks in Advance.

    The value is coming from informix db .
    Can u please suggest hw to write it in my package : 
    I have taken a OLE DB Source and wrote the follwing command :
     " select CASE WHEN T1.t_maxs IS NULL THEN 0.00 ELSE T1.t_maxs END as max_inv
    from  ttiitm001010 T1 ".
    Please give details, as i am new ...

  • How to build a report in web Intelligence using Store procedure under Microsoft SQL Server 2000

    Post Author: ltkin
    CA Forum: WebIntelligence Reporting
    Hi,
    How to build a report in web Intelligence using Store procedure under Microsoft SQL Server 2000 ?
    Regards,

    Hi ltkin,
    Unfortunately, it is not possible in Xir2 to create Webi reports from stored procedures.
    Webi reports can only be created from Universe. So in Business Objects XIR3 we can create a special universe that enables Web Intelligence user's to access stored procedures residing in the database. This is the only way that Web Intelligence user's can access stored procedures.
    Please let me know if the above information helps.
    Regards,
    Pavan

  • Oracle 10g connectivity with sql server 2000 through oracle transpa gateway

    dear gurus.
    i am to connecto oracle 10g with sql server 2000 through oracle transparent gateway.
    i have installed transparent gateway and proper configured. also link is created.
    but when i execute query "select * from city@inventory" , so an error displayed.
    ORA-12500: TNS:listener failed to start a dedicated server process.
    kindly suggest me what could be the cause.
    regards,

    if the listener fails to spawn a dedicated server process it is commonly indicating an issue with the listener. So posting the listener and also a listener trace including a description of the env where you installed the gateway into which directory would be helpfull. Please keep also in mind if you have for example a 10.2.0.3 database and you install into this directoty a 10.2.0.1 gateway you have to reapply the patchset again do get consistent file version.
    So please describe more detailed your env.

  • How to load oracle data into SQL SERVER 2000?

    how to load oracle data into SQL SERVER 2000.
    IS THERE ANY UTILITY AVAILABLE?

    Not a concern for an Oracle forum.
    Als no need for SHOUTING.
    Conventional solutions are
    - dump the data to a csv file and load it in Mickeysoft SQL server
    - use Oracle Heterogeneous services
    - use Mickeysoft DTS
    Whatever you prefer.
    Sybrand Bakker
    Senior Oracle DBA

  • How to use OEM to moniter sql server 2000

    Hi,
    I need to learn How to use OEM to moniter sql server 2000.
    Can anyone help me and give me some website or documents
    to read?
    So I can learn to do this job.
    Thanks.

    See Note 115302.1 in Metalink.oracle.com
    in how to use OEM Diagnostic pack addon for SQL Server
    Or search for
    oem "user events"
    to build your own monitor script.

  • Error Establishing Socket with SQL Server 2000

    I have a java application that uses JDBC to connect to a source of data.
    The application has been installed on many platforms using many different data sources, but one combination has beaten me.
    I am using Windows Server 2003 and SQL Server 2000 Enterprise, when the application starts up it fails to connect to the database with the following message:
    [Microsoft][SQL Server 2000 Driver for JDBC] Error Establishing Socket
    I have looked at a lot of forums and tried many things but nothing has fixed the problem for me:
    To summarise:
    The URL I am using is jdbc:microsoft:sqlserver://locahost:1433
    I have also tried using the name of the machine and it's actual IP address
    I have checked that TCP/IP is enabled and using the correct port (1433)
    Both SQL Server and Windows authentication are enabled and I can connect using both method from ODBC
    I can connect to it and use it with c#.net, vb.net and ODBC from the same machine
    I have installed the latest SQL Server 2000 service pack
    The application works with SQL Server 2000 Developer on Windows XP
    If anyone has any other suggestions, I would love to hear from you.

    If you printed out the SQL state and error code that would be a bit more info:
    catch (SQLException e)
        e.printStackTrace();
        System.err.println("SQL state: " + e.getSQLState());
        System.err.println("SQL error: " + e.getErrorCode());
    }Maybe that will give you more detail as to exactly why this is happening.
    The only other thought I had was security. Maybe there's a permission to access the port that would have to be granted explicitly as part of M$'s new emphasis on security. You did say it was Windoze Server 2003. Maybe that's the difference between all the other installs and this one.
    No joy from me, sorry. - MOD

  • Using flash to display images from sql server or file system

    hello,
    what methods and parameters of the urlloader class we have to use to display images in a flash player if possible..
    also movie should update everytime a new image is added to a database or file
    the images can either be in a file system or in a sql database (if possible)
    does flash comes with an object of this type or we have to create it.
    regards,

    i responded to your duplicate message 4 days ago:
    is it possible to insert and retrieve images from sql server using actionscript.
    you'll need server-side script to query your database and you can use the flash urlloader class to call your script.
    also  is it possible to create a flash scrolling gallery based on images  stored in a database and everytime an image is added it is displayed in  the gallery.
    load the data using the urlloader class and  then load the images.  periodically query the database for new images if  there's no direct way for flash to know a new image was added.

  • How can i Display images with may own table

    Hi
    I want display images with my own table. How can I use in this query.
    SELECT    '<a href="#" onclick="javascript:'
           || 'getImageHeight(''my_img'
           || '#ROWNUM#'');javascript:redirect'
           || '(''f?p=&APP_ID.:212'
           || ':&SESSION.:DISPLAY:NO::P212_IMAGE_ID:'
           || ID
           || ''');">'
           || '<img src="#IMAGE_PREFIX#edit.gif" '
           || 'alt="Edit"></a>' ID,
              '<img id="my_img'
           || '#ROWNUM#" src="#WORKSPACE_IMAGES#'
           || filename
           || '"/>' image
      FROM wwv_flow_filesThanks
    Nr
    Edited by: user10966033 on Sep 28, 2009 1:41 PM

    You don't use #workspace_images# since that is for STATIC files, not images in a table..
    see this thread for help: Re: Display image from blob
    Thank you,
    Tony Miller
    Webster, TX

  • How to store Marathi Character in SQL server?

    I am going to design a application having front end with VB.Net and Back end with SQL SERVER in. And I want the complete interface of that
    application in marathi language.
    when I enter the marathi character in data base and execute it, it shows "????????" like this.
    What I do to enter and store the marathi character in Database?

    Are you saying in application it is showing ???? ? In that case check the locale? If you are seeing this behaviour in DB Check this
    create table test(col nvarchar(22))
    insert test SELECT N'नमस्कार'
    insert test SELECT 'नमस्कार'
    select *from test
    BTB... Namaskar DAN... :)
    Madhu
    MCITP, MCTS, MCDBA,MCP-- Blog : http://experiencing-sql-server-2008.blogspot.com/

  • How to Read the Image in SQL server

    I want to read the image from SQL server using labview.In our project languages used are JAVA and Labview
    Through java we acquiring the image and write in to SQL Server.
    Through Labview I want to read the image form SQL server and i will do some image processing for my application.
    My problem when I seen the database the images shown like hex decimal value.
    I want to convert the hexadecimal value to image or any other functions is there to directly read the image from SQL server.
    Can anybody help me....

    two options:
    1. save the image data itself (as a blob)
    2. save the image in a file system and save the file name in the DB

  • How to use lexical parameters with Sql Server Stored Procedure?

    Hi,
    I'm developing a BI Publisher report on a sql server database. I need to execute a stored procedure to dynamically build the query by replacing the lexical parameters with the values of varaibles of the stored procedure. With Oracle stored procedures, I have used data template and had reference the varaiable in SP by prefixing it with '&'.
    It doesn't work if I try to do the same thing with SQL server. Is there anyone who has come across the similar situation? Please let me know if anyone has got any ideas...
    Thanks in Advance
    Rag

    TopLink currently doesn't support multiple ResultSets. Multiple ResultSets support is considered for a future release.

  • How to transfer database tables from sql server 2000 to oracle 10g

    Hi,
    I have a database and tables in sql server 2000. I have to transfer those data to Oracle 10g. I have installed Oracle warehouse Builder ETL Tool. Using this how can i transfer data. Any help is vary helpful for me.
    Thanks in advance.

    you have to do it using ODBC HS.
    1. Configure ODBC connection through gateway.
    2. Create a initxxx.ora file with HS config.
    restart gateway listener services
    3. on target o/s add entries to your tnsnames.ora
    4. On your target o/s create a db link
    restart listener on target
    cheeck this out.Non-Oracle connection through HS issue
    Edited by: Darthvader-647181 on Jan 29, 2009 2:02 AM

Maybe you are looking for

  • ESS leave request workflow : not able to approve request

    Hi experts, When i create leave request, work item for approving request is not coming in the approver's bussiness workplace. I am using std workflow WS12300111. Is there any customization needs to be done ?? please help me Pointes will be rewarded R

  • Track order issues

    I'm having this trouble with itunes and track orders: Lately all cds that I've added to my collection got the wrong track order, the last song showing right after the first. I'm pretty sure all tracks share the same metadata for artist, album artist,

  • E4200 Download Site not working?

    I notcied the download page for the firmware has changed, but you can no longer download the firmware?

  • Unknown files being attached to outgoing mail

    I recently sent an email to a friend who is on an AOL acct. I attached a JPEG to the email, and that came across fine. Also attached to the email were 4 .txt files (0001.txt, 0002.txt, etc) These files contained 'gibberish' according to the recipient

  • ITunes won't open after recent computer repairs

    I have an old iMac G3. Recently it refused to boot up, so I took it to a tech guy who saved the stuff I had on the hard drive to an external drive (a 500GB Lacie d2 quadra). He then restored the iMac. When I try to open iTunes I get a message that sa