Query.asp -
<%@ LANGUAGE="VBSCRIPT" %>
-
<!-- #include file="../../includes/dbconn.asp"-->
-
<%
-
dim MyRs, sqlstr, MyConn
-
-
Response.Expires = 0
-
Response.Buffer = TRUE
-
Response.Clear
-
Response.ContentType = "image/gif"
-
-
Set MyConn = Server.CreateObject("ADODB.Connection")
-
MyConn.Open dbConn
-
Set MyRs = Server.CreateObject("ADODB.Recordset")
-
-
sqlstr="select img from img"
-
MyRs.Open sqlstr, MyConn, adOpenKeyset, adLockOptimistic
-
Response.BinaryWrite MyRs("img")
-
Response.End
-
-
MyRs.Close
-
MyConn.Close
-
-
set MyRs=nothing
-
set MyConn= nothing
-
%>
Main.asp -
<HTML>
-
<HEAD><TITLE>Display Image</TITLE></HEAD>
-
<BODY>
-
This page will display the image New Moon Books from a SQL Server
-
image field.<BR>
-
<IMG SRC="Query.ASP">
-
</BODY>
-
</HTML>
why can't display, really dunno what to do
7 4224
Hi Alex,
Try changing the SQL query as follows: - SELECT [img].[img] FROM [img];
SQL does not like parent and child objects (the child/ren field/s of the parent table) to have identical names as it can confuse things.
The square brackets should act as field name delimiters so the first lot of text in square brackets identifies the table name, followed by the field name.
Failing that, rename the image binary data field to something different, for example ImgData and let us know how you get on.
You also were calling your SQL statement twice - using the Open command with a SQL string as a parameter automatically executes the SQL and returns the results. I removed the line where you used MyRs.Execute.
And finally, simple question - but do you have any image data stored in your database at present?
Best regards,
medicineworker
Hi Alex,
Try changing the SQL query as follows: - SELECT [img].[img] FROM [img];
SQL does not like parent and child objects (the child/ren field/s of the parent table) to have identical names as it can confuse things.
The square brackets should act as field name delimiters so the first lot of text in square brackets identifies the table name, followed by the field name.
Failing that, rename the image binary data field to something different, for example ImgData and let us know how you get on.
You also were calling your SQL statement twice - using the Open command with a SQL string as a parameter automatically executes the SQL and returns the results. I removed the line where you used MyRs.Execute.
And finally, simple question - but do you have any image data stored in your database at present?
Best regards,
medicineworker
I have fields with named id (int),img (BLOB) in my table called img.It is correct? and I manually insert a picture through the MySQL yog(db administration interface)
Hi Alex
I have fields with named id (int),img (BLOB) in my table called img.It is correct?
As mentioned previously, add the square braces and the full-stop, and rename the "img" field to ensure that MySQL is reading the query correctly, otherwise it will be interpreted as "SELECT myTable FROM myTable" - as we all know you can't select a table from a table, so by definition it's not correct.
medicineworker
pbmods 5,821
Recognized Expert Expert
Heya, Alex.
The exciting part of computer programming is getting a machine that does exactly what you tell it to do... to do what you want it to do.
You set up your table correctly, and your query looks right... but the server is misinterpreting it. Try adding the proper delimiters to eliminate the possibility of ambiguity in your query.
Hi Alex
As mentioned previously, add the square braces and the full-stop, and rename the "img" field to ensure that MySQL is reading the query correctly, otherwise it will be interpreted as "SELECT myTable FROM myTable" - as we all know you can't select a table from a table, so by definition it's not correct.
medicineworker
Display.asp -
<HTML>
-
<HEAD><TITLE>Display Image</TITLE></HEAD>
-
<BODY>
-
<IMG SRC="Query.asp">
-
</BODY>
-
</HTML>
Query.asp -
<%@ LANGUAGE="VBSCRIPT" %>
-
<!-- #include file="../../includes/dbconn.asp"-->
-
<%
-
dim MyRs, sqlstr, MyConn
-
-
Response.Expires = 0
-
Response.Buffer = TRUE
-
Response.Clear
-
Response.ContentType = "image/gif"
-
-
Set MyConn = Server.CreateObject("ADODB.Connection")
-
MyConn.Open dbConn
-
Set MyRs = Server.CreateObject("ADODB.Recordset")
-
-
sqlstr="select file from img"
-
MyRs.Open sqlstr, MyConn, adOpenKeyset, adLockOptimistic
-
Response.BinaryWrite MyRs("file")
-
Response.End
-
-
MyRs.Close
-
MyConn.Close
-
-
set MyRs=nothing
-
set MyConn= nothing
-
%>
My table is called img with fields id(int) and file (blob) . It's correct? why i still can't display.Thanks
hi, i was wandering....ca n you match the picture name with table primary key, so for my project i want to display a picture which also mathces with the primary key with a record, and display it on the screen, automatically.
as when users click the menu from pictures menu, the code automatiicaly does this, and beside the picture i want to display the record details.
thanks....
ok i guess nobody knows how to do it
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Alper Adatoz |
last post by:
Hi,
i have a little problem. i hope u guys give me a clear solution (:
db: mssql
i just want to put jpeg file to the image field at the mssql db.
and after that i want to call it back..
|
by: Dan Anderson |
last post by:
I have created a BLOB field to store images. Is there any way to embed
them within HTML with something like:
<image start: jpeg>
</image>
Thanks in advance,
Dan
|
by: david |
last post by:
Hi,
I have asp pages running from a MySQL database.
I have placed a path in the required field (although not quite sure on
the correct format).
My asp page is just displaying the text path instead of the image.
I'm using response.write.
The Folder is called : images
|
by: John Smith |
last post by:
I know that uploading an image to a database has been covered, oh, about 3
trillion times. However, I haven't found anything covering uploading to a
MySQL database with .net. Please don't recommend storing the image to the
filesystem and only keeping a pointer to that in the table. I want to dump
the image to a table. My code dumps the data into the table, however, I get
the following error when trying to view the image "the image ......
|
by: Objectifnet |
last post by:
What I really want to do is to be able to link two pages together using an ID, The table involved displays an image stored on the File Server that has the image details stored in the Database called. THE Database used is MySQL
"Support" on a Table Called "profiles":
The problem is how do I get this piece of codes to link to a details page called "PATRONS_DETAILS.PHP" and display information about one particular database detail. With ID...
| |
by: cybervigilante |
last post by:
I can't seem to change the include path on my local winmachine no
matter what I do. It comes up as
includ_path .;C:\php5\pear in phpinfo() but there is no such file. I
installed the WAMP package and PEAR is in c:\wamp\php\pear
I modified php.ini in the c:\wamp\php directory to reflect the actual
path, but even stopping and restarting my server shows the c:
\php5\pear path. I can't change it no matter what I do I also tried
the...
|
by: tanyali |
last post by:
my .png files r stored as a blob in MySql,
I wanna to display them out in php through a web browser.
this is part of code (in php):
---after connect to database ,
$dbQuery=" select name, png1, png2 from png";
$result=mysql_query($dbQuery) or die("Could not get file list");
// to display
|
by: mirianCalin |
last post by:
i am doing a site for appliance center..
i need to display all the products that the company offers, but my problem is that i cant display ALL the images in my database.. the first entry on the database is the only one that displays..
i am using mysql as database
here's the code.. tell me what's my error and pls. kindly edit it..
**imgdata = it is where i store the image.. longblob is the data type
<?php
$errmsg = "";
|
by: msmjsuarez |
last post by:
how can i display both image and other information in the web page using php?
i'm using mysql database.
I do displaying the image only but i want to display both other information from the database and the image from the database also in one web page...
how can i do this?
pls help.....
thanks.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |