Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases 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 December 16th, 2003, 05:26 AM
Registered User
 
Join Date: Dec 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default storing an image in a database

Hai,
Now,I am learning ASP through MSAccess Database.I want to store and retrive an image.
To store an image i used OLE Object in the MSaccess database.

To store an image through ASP,i used the HTML \"input\" tag of type \"file\".we can specify the file name through brouse button.the output of the upload file is the rawdata + image,i seperated the image and stored in a variable.while
storing this in a database through asp code,I am getting this error.


Error Type:
Provider (0x80040E21)
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
/uploadfile.asp, line 33



so,give me the code for that or correct the code.
my id is nagdandey@rediffmail.com

This is the code :

1)file.HTML

<FORM NAME="oForm"
ACTION="uploadfile.asp"
ENCTYPE="multipart/form-data"
METHOD="post">
<pre>
<INPUT TYPE="file" NAME="oFile1" Accept="image/*">

<br>
<INPUT TYPE="submit" VALUE="Upload File">
</pre>

</FORM>


2)uploadfie.asp [error]

<%
option explicit
Dim FormSize,FormData,bnCRLF,Divider,DataStart,DataEnd

FormSize = Request.TotalBytes
FormData = Request.BinaryRead(FormSize)
bnCRLF = chrB(13) & chrB(10)
Divider = LEFTB(FormData,INSTRB(FormData,bnCRLF) - 1)
DataStart= INSTRB(FormData,bnCRLF & bnCRLF) + 4
DataEnd = INSTRB(DataStart + 1,FormData,Divider) - DataStart
Response.ContentType = "image/gif"
Dim Image
image = MIDB(FormData,DataStart,DataEnd)
'Response.BinaryWrite image
'Response.End
%>
<html>
<body>

<%

Dim con,conStr,rs,sQl
conStr =\"Provider =Microsoft.Jet.OLEDB.4.0;Data Source =C:\work\nag\website\databases\raw.mdb;Persist Security Info = False "

Set con = Server.CreateObject("ADODB.Connection")
con.open conStr

Set rs =Server.CreateObject("ADODB.RecordSet")
rs.open "select * from rawtable where 1=0",con,0,2,0
'If request.Servervariables("REQUEST_METHOD") = "POST" Then
rs.addNew

rs(1) =image
rs.UpdateBatch
dim sql1
sql1="insert into rawtable (rawtext) values(" + image +")"
'con.execute(sql1)
Response.write("<center><b>Inserted Successfully</b></center>")
'End If

%>
</Body>
</html>

3)database

Name of the database is raw.mdb

in the raw.mdb,a file named rawtext table is there.
the rawtext table contains two fields rawid and rawtext.

ok.
please help me.
WAITING FOR UR REPLY.
Bye.


 
Old December 16th, 2003, 02:06 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

You really don't want to store image files in an Access database. You can create a function that removes the .gif extension and stores the image name in the db and also sends the file to an upload/images folder. If you need to view the image you can then append the .gif extension when you pull the image name out of the db.

 
Old December 17th, 2003, 05:39 AM
Registered User
 
Join Date: Dec 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by stu9820
 You really don't want to store image files in an Access database. You can create a function that removes the .gif extension and stores the image name in the db and also sends the file to an upload/images folder. If you need to view the image you can then append the .gif extension when you pull the image name out of the db.

Quote:
quote:
        I don't know how to remove .gif extention from the file.please send the code for me.It is part of my project.I am doing a project in asp with northwind database.what I have to do is to display the data of the tables.if it is an image,i want to display the image.If u know the code for that please help me.I need taht one.
Ok.
Bye





Similar Threads
Thread Thread Starter Forum Replies Last Post
storing image url in sql 2000 sbushe Classic ASP Databases 0 January 28th, 2008 02:28 PM
Problem While Storing image File kiran_p2p Java GUI 0 January 4th, 2007 11:41 PM
Storing Videos to Database... ankur_icfai SQL Server 2000 2 October 19th, 2006 01:18 AM
Uploading an image and storing its name in a DB SKE Classic ASP Databases 1 March 14th, 2005 09:13 AM
Storing Graphic Image on Sql Server kasie ADO.NET 3 March 27th, 2004 04:51 AM





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