Insert a list of image in database
Hi to all,
this is the scenario:
1) Windows Server 2003 32 bit
2) Oracle 10g 32 bit
In my schema I have created 2 tables and a work dir (this dirrectory reside on the server):
CREATE TABLE MYSCHEMA.FLAGS$
FLAGS_ISO31661A2 VARCHAR2(2 BYTE),
FLAGS_NAME VARCHAR2(6 BYTE)
CREATE TABLE MYSCHEMA.IMAGE_TEST
TEST_NAME VARCHAR2(2 BYTE),
TEST_IMAGE BLOB
CREATE OR REPLACE DIRECTORY
FLAGS_DIR AS
'D:\flags';
GRANT READ, WRITE ON DIRECTORY FLAGS_DIR TO MYSCHEMA WITH GRANT OPTION;The table FLAGS$ contains the ISO code (alpha 2) and the gif name of the flags; for example:
ad ad.gif
ae ae.gif
af af.gif
ag ag.gif
ai ai.gif
al al.gifI have also created this procedure
CREATE OR REPLACE PROCEDURE MYSCHEMA.INSERT_BLOB
AS
vBlob BLOB;
vBfile BFILE;
CURSOR curFlags
IS
SELECT *
FROM FLAGS$
ORDER BY FLAGS_ISO31661A2;
BEGIN
FOR vFlag IN curFlags
LOOP
INSERT INTO IMAGE_TEST
VALUES (vFlag.FLAGS_ISO31661A2, EMPTY_BLOB ())
RETURNING TEST_IMAGE
INTO vBlob;
vBfile := BFILENAME ('FLAGS_DIR', vFlag.FLAGS_NAME);
DBMS_LOB.fileopen (vBfile);
DBMS_LOB.loadfromfile (vBlob, vBfile, DBMS_LOB.getlength (vBfile));
DBMS_LOB.fileclose (vBfile);
END LOOP;
END;
/All is created without errors; but when I execute the INSERT_BLOB procedure this error is returned:
Error at line 1
ORA-22288: file or LOB operation FILEOPEN failed
No such file or directory.
ORA-06512: at "SYS.DBMS_LOB", line 523
ORA-06512: a "MYSCHEMA.INSERT_BLOB", line 21
ORA-06512: a line 2Note that if I use a procedure without the cursor and with the absolute value like 'ad' and 'ad.gif', all work fine.
Can someone help me ?
Thank You and Best Regards.
Gaetano
Modularise your code. The base module should be to insert/load a single image. Then call this module from another module that does the "bulk image" load, and use the base module to insert a single image at a time.
E.g.
create or replace procedure LoadImgage( dirObject varchar2, fileName varchar2 ) is
begin
exception when ...
.. e.g. raise an application error listing the filename and dirobject if an ORA-22288 occurs
end;The main code unit then simply need to call this module:
create or replace procedure LoadFlagsImages is
begin
for c in (select ... ) loop
LoadImage(
dirObject => 'FLAGS_DIR',
fileName => c.flags_name
end loop;
exception when ..
.. decide what to do when LoadImage() raises
.. an exception
end;This approach will identify the problem file that fails to load. And enables the image load to be tested for that specific file only, the module to be reused elsewhere, and instrumented to record what files have been requested to load, how long the load was, number of bytes loaded, success/error code of the load, etc.
If you engineer software correctly, using modularisation, then running into the error you did is a minor event. Easily diagnosed and easily corrected.
Similar Messages
-
Insert Image in SharePoint List & Display Image from SharePoint List using C# Pragmatically
hi
i have a share point custom list with the following columns and its types.
Title--------------->Single line of test
FirstName--------------->Single line of test
LastName--------------->Single line of test
Description--------------->multiple line of test
Link--------------->Hyperlink or Picture
Image--------------->Hyperlink or Picture
I've to create a visual web part with the following input fields and which can insert following items in the above list columns
Title asp textbox
First Name asp textbox
Last Name asp textbox
Description asp textbox
Link asp textbox
Image file upload control
Submit asp button
when i click browse button for image control in above web part it browses image .jpg,jpeg or .png file from my computer into image input field above and when i click submit button it must be submitted in the Image column in the above list.
i want to know how can i do that in c# pragmatically.
i've another visual web part which should read the image from the list in Image column and display it in image control on the web part.
like this
<img id="imgdisplay" runat="server" src="" />
how can i read image from image column through c# pragmatically.Hello,
You can't directly add picture into "Hyperlink or Picture" column because this column takes URL value and image is binary etc. You can first upload that picture into picture library (create new picture or document library) then add that image link
into that column.
To add/edit "Hyperlink or Picture" column, SP provided special class called "SPFieldUrl". Wheer you need to pass URL and description as parameter.
Refer this link for you ref:
http://stackoverflow.com/questions/23829576/how-to-decide-sharepoint-url-field-is-set-as-hyperlink-or-picture
Hope it could help
Hemendra:Yesterday is just a memory,Tomorrow we may never see
Please remember to mark the replies as answers if they help and unmark them if they provide no help -
I am trying to insert or embed and image into cfmail from a database-stored path to an actual image. The actual JPEG image is stored in a folder called "images_personnel". The path to the image under the column titled photopath is stored in my database table as "/file/images_personnel/28.jpg". Displaying the image on the screen renders without a problem, embedding the same image as part of a cfloop query does not insert/embed the image into an email. All of the other output of the same cfloop displays and emails just fine. However none of the photos of each personelle show up. What an I doing wrong?
My code is below:
<cfquery name="Staffreport" datasource="master">
Select staffreport.*, name.personnelid, name.email, name.last, name.noiid, stafflt, CONCAT(name.fname,' ',name.middle,' (',name.last,')') AS teammember, CONCAT(name.fname,' ',name.middle) AS teammember2, concat(name.photopath,'',name.photo)as hisphoto, stafflt.*, trim(concat(ltfname,' ',ltmiddle)) as LT from Staffreport, name, stafflt
where 0=0
and stalt = '#Session.user_id#'
and ltid = '#session.user_id#'
and staweekbegin = <cfqueryparam value="#form.staweekbegin#" cfsqltype="cf_sql_date" />
AND staweekend = <cfqueryparam value="#form.staweekend#" cfsqltype="cf_sql_date" />
AND stapersonnelid = personnelID
<!---AND ltid = stalt--->
AND CITY = 'richmond'
AND STATUS <> 'd'
AND STATUS <> 'T'
AND type = 'personnel'
Group by personnelid
Order by teammember
</cfquery>
<cfmail>...
<cfloop query="staffreport"><br />
<table width="90%" border="0" cellspacing="2" cellpadding="4" align="left">
<tr>
<td colspan="2" align="center" valign="top" nowrap="nowrap" bgcolor="cccccc"><strong><font color="black"><cfif #staffreport.last# eq ".">#Ucase(Staffreport.teammember2)# <cfelse>#Ucase(Staffreport.teammember)#</cfif> - ID: <cfoutput>#Staffreport.noiid#</cfoutput></font></strong></td>
</tr>
<tr>
<td align="left" valign="top" nowrap="nowrap" bgcolor="#000000">Name:</td>
<td>#Staffreport.teammember#</td>
</tr>
<tr>
<td bgcolor="E6E1FD">Photo:</td>
<td bgcolor="EBEBEB">
<img src="#staffreport.hisphoto#" alt="Photo" width="98" height="98">
</td>
</tr>
<tr>
<td bgcolor="E6E1FD">Email:</td>
<td bgcolor="EBEBEB">#staffreport.email#</td>
</tr>
</table>
</cfloop>
</cfmail>You'll need to provide a full URL link to the image ("http://mywebserver/file/images_personnel/28.jpg"), not just a relative path. Remember, the email client that is used to view the email content knows nothing of the internals of your web server - it can only follow a complete URL to get images and other resources.
-Carl V. -
i want to insert a image in database(mysql) using servlet/jsp.
please help me outtry it using file IO. when the file is read and store that in object and then try to insert
-
Want to insert and retrive an image in DB2 database
Plz can anybody tell me ,hw to insert and retrive an image from DB2 database...using SERVLET.....
I am also facing a problem of hw to call a servlet in JSP page...as i m new to servlets....Plz i need help as soon as possible in detail
Thanx in advance.....You're here in an English forum. You would do our (and therefore also yourself!) a lot of favour if you write your posts in correct English. Please also elaborate about the technical coding problem in detail, so that we can provide you more specific help. I only see some requirements and complains in your post.
Anyway, all what I can do for you at this moment is to suggest you to carefully read the Java EE tutorial to learn about JSP's and Servlets: http://java.sun.com/javaee/5/docs/tutorial/doc Once you're finished with that, then go through the JDBC tutorial to learn about the Java database communication API: http://java.sun.com/docs/books/tutorial/jdbc -
Error while getting image from database in SUP using ios?
Hi All,
Im developing native iOS application using sup 2.1.3 . Im getting error While retrieving image from SUP database. Here i'm trying to get image from database and show in imageView.can any one help me how to fix this issue?
In database image datatype is 'LONG Binary' .
My table Schema:
CREATE TABLE dba.ImagesTable (
RowID INT NOT NULL,
ImageName VARCHAR(20) NOT NULL,
PhotoData LONG BINARY NOT NULL,
IN SYSTEM
ALTER TABLE dba.ImagesTable
ADD CONSTRAINT ASA137 PRIMARY KEY CLUSTERED (RowID)
ALTER TABLE dba.ImagesTable
ADD CONSTRAINT ASA138 UNIQUE NONCLUSTERED (RowID)
in Xcode:
[SUP107SUP107DB synchronize];
SUP107ImagesTable *imgTable =[[SUP107ImagesTable alloc]init];
SUP107ImagesTableList *list =[SUP107ImagesTable findAll];
SUP107ImagesTable * oneRecord =[list objectAtIndex:0];
NSLog(@"rowId:%d---imageName:%@---photoData:%@---photoLenght:%d",oneRecord.rowID,oneRecord.imageName,oneRecord.photoData,oneRecord.photoDataLength);
NSData *tempData =[[NSData alloc]init];
SUPBigBinary *responseBinaryData = (SUPBigBinary *)oneRecord.photoData.value;
@try {
[responseBinaryData openForWrite:[oneRecord.photoData length]];
[responseBinaryData write:tempData];
@catch (NSException *exception) {
NSLog(@"exception: %@",[exception description]);
UIImageView *imgView =[[UIImageView alloc] initWithFrame:CGRectMake(50,50,100,100)];
[self.window addSubview:imgView];
UIImage * tempImage =[UIImage imageWithData:tempData];
imgView.image = tempImage;
[responseBinaryData close];
Error Log:
2014-04-02 18:42:15.150 SUP102[2873:70b] rowId:1---imageName:Apple---photoData:SUPBigBinary: column=c pending=1 allow_pending_state=1 table=sup107_1_0_imagestable mbo=0x0 key=(null) ---photoLenght:90656
Printing description of responseBinaryData:
<OS_dispatch_data: data[0xc891b40] = { leaf, size = 90656, buf = 0x1213a000 }>
2014-04-02 18:42:33.304 SUP102[2873:70b] -[OS_dispatch_data openForWrite:]: unrecognized selector sent to instance 0xc891b40
2014-04-02 18:42:33.305 SUP102[2873:70b] exception: -[OS_dispatch_data openForWrite:]: unrecognized selector sent to instance 0xc891b40
2014-04-02 18:42:33.305 SUP102[2873:70b] -[OS_dispatch_data close]: unrecognized selector sent to instance 0xc891b40
2014-04-02 18:42:33.306 SUP102[2873:70b] [ERROR] [AppDelegate.m:497] NSInvalidArgumentException: -[OS_dispatch_data close]: unrecognized selector sent to instance 0xc891b40This thread talks about uploading image to SAP from a IOS device,Sending Image to SAP via iOS Native app (SUP 2.1.3)
Midhun VP -
Hi All,
I have a table with 3 BLOB columns to store images and a NUMBER type column to store the image id_no. I am using database 10g and Forms 6i
My problem is I recently updated the database from 8i to 10g, and since then I am unable to update or insert the new images in these BLOB columns. When I update the existing image or insert new image record through forms, It does save the changes in existing or new record. But It does not show these images while query the record. and also does not give any error while executing the query in forms.
But while trying to retrive the image from updated records or new record in reports, It throughs the error that image is format is unreadable or currupt.
There wasn't any problem in 8i, i could update the record as many times I wanted or create as many records as needed.
Is anybody have any clue about this problem! Any help in this regard will be highly appriciated.
Thanking you and Best Regards.You should not save an image to database, since it'll make database slow, and difficult to write a web page to load image.
Save an image to specific location, and save image location to database.
Then, use <img> tag to call an image in web page. -
FileNotFoundException Uploading image to database
Hello
I'm trying to upload image to databases, in my server it works perfectly but when i run the application in the hosting appear FileNotFoundException.
This is the part of html file than call to servlet.
<FORM ACTION="http://hosting/servlet/lordcyb3r.Connect">
<center><h4><b>Insert image</b></h4></center><BR><BR>
Name:
<input type="text" class="bginput" name="nombre" value="" size="40"/><BR>
<input type="hidden" name="c" value=""/>
<input type="file" class="bginput" name="image" size="40"/><BR>
Comment:
<input type="text" class="bginput" name="comentario" value="" size="60"/><BR>
<INPUT TYPE="SUBMIT" VALUE="Insert">
</FORM>
This is the get method of Connect servlet
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String nombre = request.getParameter("nombre");
String ruta = request.getParameter("image");
String comentario = request.getParameter("comentario");
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Connection connection = DriverManager
.getConnection("jdbc:mysql://host/db?user=userid&password=psw");
PreparedStatement ps = connection
.prepareStatement("insert into imagedata values ( ?, ?, ?, ? )");
ps.setString(1, nombre);
ps.setString(2, ruta.substring(ruta.lastIndexOf("/") + 1));
ps.setString(3, ruta.substring(ruta.lastIndexOf(".") + 1));
ps.setString(4, comentario);
ps.execute();
ps = connection
.prepareStatement("insert into image values ( ?, ? )");
File file = new File(request.getParameter("image"));
InputStream is = new FileInputStream(file); // LINE 86 <--- HERE IS THE EXCEPTION
ps.setString(1, nombre);
ps.setBinaryStream(2, is, (int) file.length());
ps.execute();
is.close();
connection.close();
out.println("<br><br>Imagen insertada con �xito");
} catch (InstantiationException e) {
out.println("<br><br>InstantiationException");
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
out.println("<br><br>IllegalAccessException");
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
out.println("<br><br>ClassNotFoundException");
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e1) {
out.println("<br><br>SQLException");
// TODO Auto-generated catch block
e1.printStackTrace();
This is the StackTrace.
java.io.FileNotFoundException: G-Natalia Duque.jpg (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at lordcyb3r.Connect.doGet(Connect.java:86)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:95)
at com.caucho.server.http.Invocation.service(Invocation.java:291)
at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:339)
at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:268)
at com.caucho.server.TcpConnection.run(TcpConnection.java:136)
at java.lang.Thread.run(Thread.java:602)
Can you help me?
I think so the method is searching the image in the server and no in the client.
If is this, How can i do it works?
Thanks for your help.to upload the file basic thump rule is the form type is multipart form data and method should be post.
u have to use any upload component to upload the file from the client machine to the server and then u have to upload it to the database
baiju -
Insert into table
values(?,?)
In one of the code for inserting image into database ,for values " ? " has been put.What am I suppose to put therre .while storing an image into oracle 9i database it gives me error as Invalid hex number.
I am using JSP as my front endcatch(Exception e)
System.out.println(e);
}Exceptions have the wonderful printStackTrace() method which show you which line and which sourcefile actually caused the exception.
byte b[]=new byte[is.available()];
is.read(b);This looks dangerous. available() is not guaranteed to return the total size of the image. -
How to store images in database and retrieve them back to page?
Well I don't know how to store an image file to a database (say MSSQL) from the JSP and retrieve it back whenever needed and put it on the JSP page? Please help me.
I am not sure how to store images in database but what you can do is store the image into particular folder using FileOutputStream and its unique name into the database...and than retrieve it from the folder using that name retrieved from database...
<%
response.setContentType("text/html");
response.setHeader("Cache-control","no-cache");
String err = "";
String lastFileName = "";
String contentType = request.getContentType();
String boundary = "";
final int BOUNDARY_WORD_SIZE = "boundary=".length();
System.out.println("contentType --> "+contentType);
System.out.println("BOUNDARY_WORD_SIZE --> "+BOUNDARY_WORD_SIZE);
if(contentType == null || !contentType.startsWith("multipart/form-data"))
err = "Ilegal ENCTYPE : must be multipart/form-data\n";
err += "ENCTYPE set = " + contentType;
else
boundary = contentType.substring(contentType.indexOf("boundary=") + BOUNDARY_WORD_SIZE);
System.out.println("boundary --> "+boundary);
boundary = "--" + boundary;
try
ServletInputStream sis = request.getInputStream();
byte[] b = new byte[1024];
int x=0;
int state=0;
String name=null,fileName=null,contentType2=null;
java.io.FileOutputStream buffer = null;
while((x=sis.readLine(b,0,1024))>-1)
System.out.println("************ x ********** "+x);
String s = new String(b,0,x);
System.out.println("************ s ********** \n"+s);
if(s.startsWith(boundary))
state = 0;
System.out.println("name="+name);
System.out.println("filename="+fileName);
name = null;
contentType2 = null;
fileName = null;
else if(s.startsWith("Content-Disposition") && state==0)
System.out.println("-- 1 --");
state = 1;
System.out.println("s.indexOf(filename=) --> "+s.indexOf("filename="));
if(s.indexOf("filename=") == -1)
name = s.substring(s.indexOf("name=") + "name=".length(),s.length()-2);
System.out.println("after name substring 1 "+name);
else
name = s.substring(s.indexOf("name=") + "name=".length(),s.lastIndexOf(";"));
System.out.println("after name substring 2 "+name);
fileName = s.substring(s.indexOf("filename=") + "filename=".length(),s.length()-2);
System.out.println("fileName --> "+fileName);
//String fileName1 = s.substring(s.indexOf("filename=") + "filename=".length(),s.length());
//System.out.println("fileName1 -->"+fileName1);
if(fileName.equals("\"\""))
fileName = null;
else
String userAgent = request.getHeader("User-Agent");
System.out.println("userAgent --> "+userAgent);
String userSeparator="/"; // default
if (userAgent.indexOf("Windows")!=-1)
System.out.println("test --> "+"\\");
userSeparator="\\";
if (userAgent.indexOf("Linux")!=-1)
userSeparator="/";
System.out.println("userSeparator "+userSeparator);
System.out.println("fileName before inserting userSeparators "+fileName);
fileName = fileName.substring(fileName.lastIndexOf(userSeparator)+1,fileName.length()-1);
System.out.println("fileName after userSeparators "+fileName);
if(fileName.startsWith( "\""))
fileName = fileName.substring( 1);
name = name.substring(1,name.length()-1);
System.out.println("name 2 --> "+name);
System.out.println("final file name "+fileName);
if (name.equals("file"))
if (buffer!=null)
buffer.close();
lastFileName = fileName;
buffer = new java.io.FileOutputStream("/Documents and Settings/sunil/Desktop/images/"+fileName);
else if(s.startsWith("Content-Type") && state==1)
System.out.println("-- 2 --");
state = 2;
contentType2 = s.substring(s.indexOf(":")+2,s.length()-2);
System.out.println("contentType2 --> "+contentType2);
else if(s.equals("\r\n") && state != 3)
System.out.println("-- 3 --");
state = 3;
else
System.out.println("-- 4 --");
if (name.equals("file"))
System.out.println("Final x :: "+x);
buffer.write(b,0,x);
} // while closing
sis.close();
buffer.close();
}catch(java.io.IOException e)
err = e.toString();
boolean ok = err.equals("");
if(!ok)
out.println(err);
else
%>
<SCRIPT language="javascript">
history.back(1);
alert('Uploaded <%=lastFileName%>');
window.location.reload(false);
</SCRIPT>
<%
out.println("done");
%>
</BODY>
</HTML>
I think it will solve ur problem.. -
Insertingand retrieving images in database using jdbc
i am new to jsp.i have to store and retrieve image files using oracle 8i.Then i have to display it using jsp.
my code for storing image is
package sample;
import oracle.jdbc.driver.*;
import oracle.sql.*;
import java.sql.*;
import java.io.*;
import java.awt.image.*;
import java.awt.*;
public class storephoto{
public static void main(String[] args){
String filename = "C:/Documents and Settings/user/Desktop/five.gif";
Connection conn = null;
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
conn=DriverManager.getConnection("jdbc:oracle:thin:@10.1.4.228:1521:data","system","manager");
conn.setAutoCommit(false);
Statement st = conn.createStatement();
int b= st.executeUpdate("insert into bfiles values('"+filename+"', empty_blob())");
ResultSet rs= st.executeQuery("select * from bfiles for update");
rs.next();
BLOB blob=((oracle.jdbc.driver.OracleResultSet)rs).getBLOB(2);
FileInputStream instream = new FileInputStream(filename);
System.out.println("instream="+instream);
OutputStream outstream = blob.getBinaryOutputStream();
System.out.println("outstream="+outstream);
int chunk = blob.getChunkSize();
System.out.println("chunk="+chunk);
byte[] buff = new byte[chunk];
int le;
while( (le=instream.read(buff)) !=-1)
System.out.println(le);
outstream.write(buff,0,le);
System.out.println(buff);
instream.close();
outstream.close();
conn.commit();
conn.close();
conn = null;
System.out.println("Inserted.....");
catch(Exception e){
System.out.println("exception"+e.getMessage());
e.printStackTrace();
}//catch
This code works fine & something gets stored in the buffer.but while rereiving nothing gets retreived.i cannot retrieve the image file
my code for retreiving is
package sample;
import java.sql.*;
import java.io.*;
import java.awt.*;
import oracle.sql.BLOB;
public class retphoto
public static void main(String a[])
String fileName ="C:/Documents and Settings/user/Desktop/five.gif";
try
Driver driver = new oracle.jdbc.driver.OracleDriver();
DriverManager.registerDriver(driver);
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@10.1.4.228:1521:data", "system", "manager");
File file = new File("C:/Documents and Settings/user/Desktop/sa1.gif");
FileOutputStream targetFile= new FileOutputStream(file); // define the output stream
PreparedStatement pstmt = con.prepareStatement("select filecontent from bfiles where filename= ?");
pstmt.setString(1, fileName);
ResultSet rs1 = pstmt.executeQuery();
rs1.next();
InputStream is = rs1.getBinaryStream(1);
System.out.println(is);
byte[] buff = new byte[1024];
int i = 0;
while ((i = is.read(buff)) != -1) {
System.out.println("hai");
System.out.println(i);
targetFile.write(buff, 0, i);
System.out.println("Completed...");
rs1.close();
is.close();
targetFile.close();
pstmt.close();
con.close();
catch(Exception e)
System.out.println(e);
}Thanks for ur help:
another Q:
in my GUI i have a button called Insert. but can't update my database table unless i create textField(e.g Firstname, Surname..ect..), so that when I click Insert button in actionEvent it will bring up popup which have field name in which i am going to insert new records.
so what iam trying to say is, how iam going to tell the actionEvent to trigger this.
the following is my code
public void actionPerformed(ActionEvent event)
ExamResults exam= new ExamResults ();
String studentId = studentTextField.getText();
if (event.getSource() == insert) //if insert is clicked
Thanks -
Getting Image from database in crystal report
Hi Experts,
I have a user UDF which has Image datatype. I store all the image in C:\Program Files\SAP\SAP Business One\Bitmaps\ folder.Now i have to show this image in my crystal report. When i tried to pick this image from database it gives me only the name of image with extension like abc.jpg . How could i achive this in crystal report.
Thanks and RegardsHi Om
As you have the location of the image, you can insert it as an OLE object onto the report.
Click on Insert -> OLE Object -> specify the path of the image.
For more information, please refer to Crystal Reports help.
Regards
Sourashree -
Image from database loaded at run time.
Post Author: Adam20002
CA Forum: .NET
I am using Crystal Reports 11. I have a report with an image in it that i want to change dynamically from my ASP.Net page. I am doing this at the moment by passing an image path in as a parameter and setting the Graphics Location property. However the requirement has changed and now the image is coming from a database. So if i wanted the user to be able to select from a list of images stored in the database and have that image appear in the report when it is loaded what would be the best way to go about it?
ThanksDid you ever find a solution to this problem? I have the same problem when moving reports from development to Test to Production environments. If the DBName is not the same the report ignores the name provided at runtime.
-
How to retrieve am image from database
hi ,
i hav a requirement that, i hav to store and retrive an image from database(postgresql)and palce it on JLabel.i successfully stored an image into database .while retrieving an image from database im not getting the image .please any one can help me how to retrieve an image and place it in JLabel.
This the code for inserting an image:
Class.forName("org.postgresql.Driver");
Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:port/database", "username", "pwd");
System.out.println("Connection established");
String INSERT_PICTURE = "insert into imagedata(imageid,data) values (?, ?)";
FileInputStream fis = null;
PreparedStatement ps = null;
try {
conn.setAutoCommit(false);
File file = new File("photo.jpg");
fis = new FileInputStream(file);
ps = conn.prepareStatement(INSERT_PICTURE);
ps.setInt(1, 2);
ps.setBinaryStream(2, fis, (int) file.length());
ps.executeUpdate();
conn.commit();
catch(Exception ex)
ex.printStackTrace();
finally {
ps.close();
fis.close();This is the code for retrieve an image :
Class.forName("org.postgresql.Driver");
Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:port/database", "username", "pwd");
byte[] imgbytes = null;
String INSERT_PICTURE = "select imageid,data from imagedata ";
Statement stmt=(Statement) conn.createStatement();
try {
ResultSet rs=stmt.executeQuery(INSERT_PICTURE);
while(rs.next())
System.out.println(rs.getString(1));
InputStream file=rs.getBinaryStream(2);
System.out.println("FILE : "+file);
catch(SQLException a)
finally {
stmt.close();please anyone can help meee
thanksYou basically save a File to the database, so you can just re-write the data from the file back temporarily and load it into the application using the ImageIO class
// create necessary connection and statement objects
// retrieve image column
ResultSet rs = stmt.executeQuery("SELECT Image FROM dataTable");
rs.next();
Blob imageData = rs.getBlob("Image");
if( imageData != null ) {
try {
File tmpFile = new File("tmpImage");
FileOutputStream fos = new FileOutputStream(tmpFile);
fos.write( imageData.getBytes(1L, (int)imageData.length()) );
fos.close();
tmpFile.deleteOnExit();
ImageIcon icon = new ImageIcon( ImageIO.read(tmpFile) );
JOptionPane.showMessageDialog(null, icon);
} catch(IOException ioe) {
ioe.printStackTrace();
JOptionPane.showMessageDialog(null, "Failed To Load Image Data", "Load Error",
JOptionPane.ERROR_MESSAGE);
}ICE -
How to insert Integer array in a MySql DataBase
Now i am doing one swing application,in that i have List box,My doubt is ,How to insert the mutiple seleted value into database.
http://java.sun.com/docs/books/tutorial/jdbc/
Maybe you are looking for
-
Magic Mouse + MagicPrefs Problem
I recently got a Magic Mouse and installed MagicPrefs, but when I try to use any keyboard shortcuts on it they don't work. I'm mainly trying to use Command T and Command W to easily open and close tabs in my web browser. I've tried different browsers
-
Varying table columns, best practices
I've been wondering about this for quite sometime now. JTable is very complex, but it has a lot of funcationality that hints at reusable models. The separation of TableModel and ColumnModel seems to hint at being able to reuse a TableModel that store
-
Setting stop time of a song in iTunes
I have done this many times before in iTunes but for some reason it is no longer working. I go to "get info", choose the "options" tab, put a check in the "Stop time" box and then put the time in that I want. As soon as I make any move to exit back i
-
LightRoom 1.2 available
http://www.adobe.com/uk/products/photoshoplightroom/
-
I'm trying to enable postfix on Mountain Lion. When I get to this step: sudo /usr/sbin/postfix set-permissions I get this error: chown: /usr/share/man/man1/postalias.1.gz: No such file or directory Any thoughts? Thanks!