Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 26th, 2010, 06:38 AM
Registered User
 
Join Date: Aug 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dababy Send a message via Yahoo to dababy
Default Displaying images from the database but got errors.

Hi all,

I want to search images and display it with my search result.

Below is the code I use but it is not working it is giving me errors.

I will appreciate any help.

my search code is working but to display images from database is the problem.



set rsSearch = Server.CreateObject("ADODB.Recordset")
sql= "SELECT File_Data" & "FROM [registration] " & "WHERE City LIKE '" & Replace(request.Form("txtsearch"), "'", "''") & "%' "
strSearch = "SELECT Brief,Area,City,Country,Telephone" & "FROM [registration] " & "WHERE City LIKE '" & Replace(request.Form("txtsearch"), "'", "''") & "%' "
rsSearch.open strSearch,strSql,strconn,3,3

%>

<%
On error resume next
rsSearch.movefirst
while Not rsSearch.eof
%>
</p>
<table>
<tr>
<td height="20" colspan="4" class="fontbold"> <%=rsSearch("Brief")%> </td>
</tr>
<tr>
<td width="217" height="20" class="font"> <%=rsSearch("Area")%> </td>
<td width="99" class="font"> <%=rsSearch("City")%> </td>
<td width="94" class="font"> <%=rsSearch("Country")%> </td>
<td width="225" class="font"> <%=rsSearch("Telephone")%> </td>
<td width="200">
<%
if not (rsSearch.EOF and rsSearch.BOF) then
PicSize = rsSearch("File_Data").ActualSize
if PicSize > 0 then
Response.BinaryWrite rsSearch("File_Data").GetChunk(rsSearch("File_Data ").ActualSize)
End if
End If

response.End

if rsSearch.eof then
respond.end
else
Response.ContentType ="image/jpeg"
Response.BinaryWrite(rsSearch("File_Data"))
end if
%>
</td>

</tr>
<%
 
Old October 26th, 2010, 03:48 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Two *BIG BIG* mistakes.

(1) In your queries:
sql= "SELECT File_Data" & "FROM [registration] " ...

You have NO SPACE between "File_Data" and "FROM". (and then between "Telephone" and "FROM" in the other query.)

*WHY* do you break up the string like that, in any case??? Keep it SIMPLE:
Code:
sql = "SELECT File_Data FROM [registration] WHERE City  LIKE  '" _
    & Replace(request.Form("txtsearch"), "'", "''") & "%' "  
strSearch = "SELECT  Brief,Area,City,Country,Telephone FROM  [registration] " _
          & "WHERE City LIKE  '" &  Replace(request.Form("txtsearch"), "'", "''") & "%' "
(2) The BIGGER error:
Code:
rsSearch.open strSearch,strSql,strconn,3,3
You can only use *ONE QUERY* per recordset!!! That code makes no sense at all. Trying to use two different queries at the same time.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Storing images in Database and displaying them Manoj Bisht ASP.NET 1.x and 2.0 Application Design 4 February 6th, 2010 03:06 AM
Displaying images dynamically from database:) Peggie1990 Servlets 3 July 10th, 2009 03:38 PM
displaying images from database(mysqlquerybrowser) in jsp:) Peggie1990 JSP Basics 6 June 29th, 2009 06:47 AM
displaying images embedded in database jia ASP.NET 1.0 and 1.1 Basics 1 July 5th, 2007 07:06 AM
Displaying Images From Database Metalore BOOK: Beginning ASP.NET 2.0 and Databases 1 November 1st, 2006 11:45 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.