Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 26th, 2010, 06:38 AM
Registered User
Points: 23, Level: 1
Points: 23, Level: 1 Points: 23, Level: 1 Points: 23, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Lagos, Lagos, Nigeria.
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>
<%
Reply With Quote
  #2 (permalink)  
Old October 26th, 2010, 03:48 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
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.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:46 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.