codetoad.com
Home||ASP|ASP.Net|C++/C#|DHTML|HTML|Java|Javascript|Perl|VB|XML||CodeToadPlus!||Forums||RAM
Search Site:
Search Forums:
display an image held in a sql database (image datatype) in to a datalist Archive Import (rob help) at 03:16 on Friday, April 11, 2003

I can load the image to the database but cant retrieve it to display it in a web page.


Re: display an image held in a sql database (image datatype) in to a datalist Archive Import (rob help) at 07:18 on Friday, April 11, 2003

many thanks who ever you are? it seem lots of work to read an image from a database. I will try the methods you suggested

Re: display an image held in a sql database (image datatype) in to a datalist Yusairi at 09:51 on Monday, July 07, 2003

hi rob...

second option :

in file test.html, put this code :-

<img src="/forum/image_id_1.html">


then, in same directory, make file image.asp
and put this code :-


<%
Response.ContentType = "image/gif"

Response.Expires = 0
Response.Buffer = TRUE
Response.Clear

id = Request.QueryString("id")

`checking the data exist or not
`Server Name=test
`SQL Server database name=test

cme = "DRIVER={SQL SERVER};SERVER=test;UID=sa;pwd=;DATABASE=test"

`field ImageItem is image datatype in SQL Server.
cmdsql = "SELECT ImageItem from EQUIPMENT WHERE id =`"&id&"`"
set rs = Server.CreateObject("adodb.Recordset")
rs.open cmdsql, cme

Response.BinaryWrite rs("ImageItem")
Response.End
%>

it works fine for me.
no DLL consider for this option.

feel free to visit http://www.vss.com.my




Re: display an image held in a sql database (image datatype) in to a datalist Archive Import (rob help) at 14:04 on Tuesday, July 08, 2003

the problem with this method is it flushes out all your code.

Re: display an image held in a sql database (image datatype) in to a datalist Yusairi at 00:21 on Wednesday, July 09, 2003

from rob :
the problem with this method is it flushes out all your code.

my answer :
flushes !, what you mean by that.
as i`m concern, this method will be getting the image datatype
from SQL Server.
very practical code.
i`m using it until now.

Re: display an image held in a sql database (image datatype) in to a datalist Troy Wolf at 15:54 on Tuesday, July 15, 2003

Both of the previous replies will work for you. The component sounds nice, but many times you may not be allowed to install components to the server. Or maybe you are on a tight budget and so do without components when possible. In which case, the second method suggested is all you need. Here is an article that provides even more detail regarding the answer you already got. Part 2 is specifically what you are looking for.

Part 1
http://www.superdotnet.com/show_article.aspx?pkID=81

Part 2
http://www.superdotnet.com/show_article.aspx?pkID=83

I can`t find Part 3, which I`d love to get my eyes on!

Troy Wolf: site expert
SnippetEdit Website Editor


Re: display an image held in a sql database (image datatype) in to a datalist dio at 19:38 on Tuesday, May 31, 2005

Hi there,

Is it possible to put an image into the database in a similar way?

Thanx!

Re: display an image held in a sql database (image datatype) in to a datalist Yusairi at 16:18 on Wednesday, June 01, 2005

hi dio,

for saving an image data type via web into SQL Server,
you can try refer this code :-

http://www.asp101.com/resources/aspupload.asp
(this code needed you to have aspupload component
from http://www.persits.com/aspupload.html)

good luck.









Re: display an image held in a sql database (image datatype) in to a datalist Troy Wolf at 00:27 on Monday, June 06, 2005

I just wanted to follow up to say that most people don't store images in the database. Instead, they just store them in the filesystem as a normal file and only save information about the file in the database. It makes for simpler code, and there usually are not any performance reasons to store large binary chunks in the database. Plus, it allows you to work with your image files natively in the filesystem if you want/need.
Troy Wolf: site expert
SnippetEdit Website Editor


Re: display an image held in a sql database (image datatype) in to a datalist dio at 10:19 on Monday, June 06, 2005

I understand what you're saying but I'm particularly interested on this approach because we are about to develop an e-business web site to sell photos!

For security reasons this seems to be the best way to do it, don't you think?

Re: display an image held in a sql database (image datatype) in to a datalist Yusairi at 12:30 on Monday, June 06, 2005

hi dio,

why don't you try change the file content into binary format and keep it in binary field (database). then, you review it using code that can convert binary into image or whatever needed. I'm believe there is a way to do this but keep try and try. Hopefully you'll find it.

smile while programming.

<Added>

or,

maybe you can using PHP code because PHP code can help you on saving your record in database. However, I'm suggesting you make another database (MySQL) to store an image because it will make your main database (MS SQL) working more faster. If you store on same database, maybe it'll effect your main process and memory. Keep going to try it. You need to know various code other than ASP. Check it out PHP and MySQL. I'm sure it will help you to make e-portal/business.

Please make sure your IIS can support PHP compiler, check it out on IIS configure with PHP.

refer this link regarding on PHP and MySQL :-

http://www.atalasoft.com/products/imgxasp/docs/Database.html (Guide to insert image)

http://www.php.net (PHP Library/Source)
http://www.mysql.com (MySQL Database)
http://www.sqlyog.com (MySQL Control Interface)
http://www.apache.org (HTTP Server) @ using IIS


GOOD LUCK.

Re: display an image held in a sql database (image datatype) in to a datalist Troy Wolf at 12:49 on Monday, June 06, 2005

dio, saving images to the filesystem rather than in a database does not present any security issues if done correctly. You can store all the images in directories that are outside the webroot. This way the images cannot be directly linked to. You can serve the images in your web pages using a script that you pass the filename to, then it reads the image server-side and streams back as an image.

I'm not saying DO NOT store in the database. I'm just saying that in my experience, I've found most people opt not to store them in the database. Honestly, I'm not sure of all the reasons why. It adds complexity to your application for one thing.
Troy Wolf: site expert
SnippetEdit Website Editor


Re: display an image held in a sql database (image datatype) in to a datalist dio at 12:49 on Monday, June 06, 2005

hey there,

I have already achieved what I wanted except for one thing, that is, save the image in the DB without using a third party component. Still, it seems this isn't possible on classic ASP.

thanx

Re: display an image held in a sql database (image datatype) in to a datalist a497253 at 22:35 on Tuesday, January 15, 2008

Hello Yusairi,

Are you still around?

How did you get this script to work? Did this work without components? It seems like the easiest script for classic asp.

I tried using the script and did not have success.

Dreamweaver 8 is my current coding tool.

Please let me know if you are still with Codetoad.








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
matrix addition
Re: Storing data from HTML to Excel or TXT
Re: function within loop problem
Re: Ô‡´ò¥¯¥é¥Ö¤Ï ¥Æ©`¥é©`¥á¥¤¥É£ò£±£±¥¢¥¤¥¢¥ó ¤Î£··¬ ¤Ç¤¹
Re: Replace
Re: タイトリスト AP2アイアン 712�情�
Re: SMS from Perl using HTTP request
Re: Charl Schwartzel
Re: Adhyayan - Annual Student Conference and Online Coding Festival


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


Copyright codetoad.com 2001-2013