473,657 Members | 2,576 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unable to open attachment

Dear Experts,

In my web application, I'm having a button to view an attachment. After I
retrieve the record from database (Ms. Access), I have a button to view the
attachment (if there is any). The button work fine when I run it at my local
machine. However, when I moved all the programs over to the server, I am
unable to view the attachment, although I have the file physically at the
server. The error message that I got is:

------------------------------------------------------------------------
Server Error in '/ITRS_Testing' Application.
--------------------------------------------------------------------------------

Operation is not allowed when the object is closed.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Runtime. InteropServices .COMException: Operation is
not allowed when the object is closed.

Source Error:

Line 26:
Line 27: ' This should be the full path and filename to save the
file on the client....
Line 28: objStream.SaveT oFile(strFilena me, 2) ' adSaveCreateOve rWrite
Line 29: objStream.Close ()
Line 30: objStream = Nothing

Source File: D:\ITRS_Testing \ITRS\EnquiryRe sult.aspx Line: 28

Stack Trace:

[COMException (0x800a0e78): Operation is not allowed when the object is
closed.]

Microsoft.Visua lBasic.Compiler Services.LateBi nding.InternalL ateCall(Object o,
Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack, Boolean IgnoreReturn) +776
Microsoft.Visua lBasic.Compiler Services.NewLat eBinding.LateCa ll(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean
IgnoreReturn) +365640
ASP.itrs_enquir yresult_aspx.Vi ewDoc(Object Source, EventArgs E) in
D:\ITRS_Testing \ITRS\EnquiryRe sult.aspx:28
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +105
System.Web.UI.W ebControls.Butt on.RaisePostBac kEvent(String eventArgument)
+107

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring eventArgument) +7
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +11
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +5102

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.507 27.42; ASP.NET
Version:2.0.507 27.42
----------------------------------------------------------------------------------

The code in my program is as follow:

Public Sub ViewDoc(ByVal Source As Object, ByVal E As EventArgs)
Dim strFilename As String
'============== =============== =============== =============== ====
' Example using ADODB Stream Object to load resource from server
' and deposit in specified directory on client, using client-side
' script
' Peter Bromberg
'============== =============== =============== =============== =====
' Don't need the TypeLib METADATA at the top if you specify the
constants by numeric value instead of by name

' Set up an ADO Stream ....
Dim objStream
objStream = CreateObject("A DODB.Stream")
objStream.Type = 1 ' adTypeBinary
' The following should be the absolute URL to the file on the
server.....
objStream.Open( "URL=http://Teklang1/ITRS_Testing/ITRS/Attachments/"
& Trim(txtAttachm ent.Text))
'objStream.Open ("//Teklang1/ITRS_Testing/ITRS/Attachments/" &
Trim(txtAttachm ent.Text))

Dim objFSO
objFSO = Server.CreateOb ject("Scripting .FileSystemObje ct")
strFilename = objFSO.getSpeci alFolder(2).pat h & "\" &
Trim(txtAttachm ent.Text)

' This should be the full path and filename to save the file on the
client....
objStream.SaveT oFile(strFilena me, 2) ' adSaveCreateOve rWrite
objStream.Close ()
objStream = Nothing
' Now we'll "run" the file....
Dim AttachFile As System.IO.FileI nfo = New
System.IO.FileI nfo(strFilename )
Response.Clear( )
Response.AddHea der("Content-Disposition", "attachment ; filename=" &
AttachFile.Name )
Response.AddHea der("Content-Length", AttachFile.Leng th.ToString())
Response.Conten tType = "applicatio n/octet-stream"
Response.WriteF ile(AttachFile. FullName)
Response.End()
End Sub
----------------------------------------------------------------------

Please advise where is the mistake that I have made. Many thanks in advance.

Regards,
SB
Feb 20 '06 #1
0 2345

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1941
by: bmcelhany | last post by:
I have a windows service that monitors a directory for newly created files. When one is found, an e-mail is generated and the new file is added as an attachment. In order to avoid trying to attach the file if it is still in the process of being written to, I'm using a routine (that I found somewhere on this site, but can't seem to locate the thread anymore...) that checks to see if that file can be opened using a FileStream. If it can, it...
0
1860
by: Steve Chatham | last post by:
I am stuck on this. It ought to be a simple reason as to why this is problematic, in that it works on smaller groups of data (say under 40 records), but doesn't on larger groups of records (40+). I'm displaying 9 columns in a datagrid, and have a radiobutton at the top of the page that says Web, Excel & Word. Web is selected by default. If you click one of the other two buttons, this code is executed: Private Sub...
3
2422
by: Chris Thunell | last post by:
I am using the following code to send email out in a vb.net web program through an exchange 2003 server. My web server is on a separate server. When i try to send email inside the office, it works fine... but when i try to send email outside the company i get "unable to relay" error message. Please look at the code, i don't see a way to send username and password credentials to allow the relaying to occur (I don't want unauthenticated...
6
3531
by: Seok Bee | last post by:
Dear Experts, In my web application, I'm having a button to view an attachment. After I retrieve the record from database (Ms. Access), I have a button to view the attachment (if there is any). The button work fine when I run it at my local machine. However, when I moved all the programs over to the server, I am unable to view the attachment, although I have the file physically at the server. The error message that I got is: ...
0
12037
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in '/CinemaBookingSystem' Application. -------------------------------------------------------------------------------- ERROR General error Unable to open registry key 'Temporary (volatile) Jet DSN for process
0
1637
by: bananularstyle | last post by:
Hi everyone, This is an issue I have been picking away at for the past two weeks and am running short of ideas. :-\ I am writing an ASP page that allows a user to open/save a tif image stored on SQL Server. The user triggers the download by clicking a hyperlink which loads getAttachment.asp (code listed below). GetAttachment.asp connects to SQL Server through an ODBC and attempts to download the specified tiff using BinaryWrite(). It...
1
1817
by: sathvinder | last post by:
I just got an email with a 8mg attachment in pdf format. It locked up my computer. I used to be able to open large size attachment without any difficulty. If I even click on the email it will lock up my computer.
1
1443
by: =?Utf-8?B?RGF2aWQ=?= | last post by:
I am using vista with microsoft mail and microsoft works. When I send a mail with an attachment, the recipient opens them and they are empty. If I send the same mail and atachment to myself, it opens correctly. Can any one help? -- David
0
1738
by: sandeep98811 | last post by:
I am getting following weird issue, "When forwarding an email with an open attachment the user warned twice that an attachment is open". I am catching Forward event of mail item in function _mail_Forward(). Steps to reproduce issue: 1. Open email , open attachment 2. Click on Forward Button, 3. Outlook displays message "The attachment "test" is open or in use by another application. If you continue, you will lose any changes you...
0
8305
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,...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
tracyyun
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...
0
7324
agi2029
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...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
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();...
0
4151
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...
1
2726
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
2
1953
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.