codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
This 16 message thread spans 2 pages: [1]  2  > >  
  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 (roger) at 04:33 on Friday, April 11, 2003
 

To store/retrieve this sort of data within TSQL scripts you have to use the
WRITETEXT and READTEXT commands rather than standard INSERT/SELECT statements.
These are documented, with examples, in the books-online but are basically a
real pain to use. There are more manageable commands available from within the
relevant programming languages - e.g. RDO and ADO from VB/C can use GetChunk
and AppendChunk commands - but you still have to manage the image/text
chunks/blocks of data at a time. About the only upside of storing this sort of
data within SQL Server is that it can be kept transactionally consistent with
the other data.

For native ODBC access use the SQLPutData and SQLGetData commands.

If you just want to insert/retrieve an entire image/text then look at the
TEXTCOPY program (textcopy /? for parameters) in the \BINN directory. It
is a command-line program along the lines of BCP.

There is a very useful (free) dll available from
http://www.chriscrawford.com/DBImage (courtesy of Chris Crawford). It has
three functions:

GetImage Used for getting an image from the database
StoreImage Used to send an image to the database
GetWebImage Used to send a DB image to a browser

If transactional consistency doesn`t matter, or can be achieved
programmatically, then it is easier to store the data outside the database as
an ordinary file. Within the database just hold a UNC pointer to where the
file is held. This usually makes it much easier to display/edit the data as
the name can simply be passed to whatever tool is doing the manipulation.



  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="image.asp?id=1">


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


Yusairi: site expert
http://www.codetoad.com


  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.
Yusairi: site expert
http://www.codetoad.com


  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.







Yusairi: site expert
http://www.codetoad.com


  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.
Yusairi: site expert
http://www.codetoad.com


  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  Yusairi at 16:42 on Wednesday, June 22, 2005
 

hi dio,

As I said, please using PHP Code which can help you much better to insert image file into database. you can separate your image database using MySQL instead of using SQL Server. I'm sure your system running on web-based and database referring to SQL Server but if your IIS (web server) had been set running ASP and PHP code properly, you can implement ASP and PHP code into your system. don't wait for any approach to come you just like that. be a good web database programmer need to implement many technique to ensure the result can be view and make our client happy ever after. hehehehee. smile man while learning.

example :

in file abc.asp, having form code :-

<form name="worldForm" action="insertImage.php">
....
....
....
</form>

Yusairi: site expert
http://www.codetoad.com


This 16 message thread spans 2 pages: [1]  2  > >  







CodeToad Experts

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








Recent Forum Threads
• matrix prblm in java
• Re: how to open instantly a pop up window whenever a user sends a message to the other user
• Re: PING PROGRAM IN PERL
• Re: date of birth validation using java script-very urgent
• JAVA If statements
• Need Help with a Regular Expression
• Informations on HTML
• Re: FREE TV on your PC!
• Re: Using Lucene or Solr ?


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-2010