All,
I’m in the process of converting an old ASP.Net (v1.1) application into an ASP.Net (v3.5) application. This application uses an OpenROAD Application Server to talk to our Ingres (9.2) database. Part of this application extracts documents from the database and downloads them to the user. Unfortunately, this is resulting in corruption of the documents. The documents are stored in the database in LongByte columns and returned to the web page using a STRING parameter.
In traditional ASP, I would simply retrieve the document parameter from the PDO object and do a Response.BinaryWrite (document) to trigger the download.
Under ASP.Net, this does not work. I’ve tried various modifications and parameter settings on the response header, but am not getting anywhere. This is my latest version of the code, which appears to download a file, but when opened by Word results in formatting corruption (but does work in ASP.Net 1.1):
Response.Buffer = True
Response.ClearContent()
Response.ClearHeaders()
Response.Expires = -1
'#------------------#'
'# Get the document #'
'#------------------#'
Dim strFile As String
objOR.DefineBPM("Web_bpm")
Dim byrefPDO As New ORPDO()
byrefPDO.DeclareAttribute("iDocument", "INTEGER")
byrefPDO.DeclareAttribute("vFile", "STRING")
byrefPDO.DeclareAttribute("document", "STRING")
byrefPDO.SetAttribute("iDocument", CInt(Request.QueryString("id")))
objOR.CallProc("getDoc_scp", , byrefPDO)
If objOR.i_error_no <> 0 Then
error_lbl.Text = objOR.v_msg_txt
Else
Dim encText As New System.Text.UnicodeEncoding()
Dim btText() As Byte
btText = encText.GetBytes(byrefPDO.GetAttribute("document"))
strFile = byrefPDO.GetAttribute("vFile")
Response.AddHeader("content-disposition", "attachment; filename=" & strFile)
Response.ContentType = "application/ms-word"
Response.BinaryWrite(btText)
Response.Flush()
Response.End()
objOR = Nothing
End If
I believe the problem is with trying to convert the STRING representation of the document into a binary array as written by the BinaryWrite method, but am unsure how I should be doing this.
Can anyone offer any advice on how I should be doing this. The application also needs to be able to download excel and pdf files from the database, so a generic conversion would be extremely useful,
Many thanks in advance,
Martin Bloomfield.
_________________________________________________
Application Developer & Database Administrator
IT Branch
Chemicals Regulation Directorate
Health and Safety Executive
YORK
Email: martin.b...@hse.gsi.gov.uk
Website: www.pesticides.gov.uk www.hse.gov.uk
P Save a tree... please don't print this e-mail unless you really need to
*****************************************************************************************************************
Please note : Incoming and outgoing email messages are routinely monitored for compliance with our policy on the use of electronic communications and may be automatically logged, monitored and / or recorded for lawful purposes by the GSI service provider.
Interested in Occupational Health and Safety information?
Please visit the HSE website at the following address to keep yourself up to date
*****************************************************************************************************************
Have you tried to use ”BINARY” instead of “STRING” in the DeclareAttribute for parameter “document”?
Bodo.
Bodo Bergmann | Sr. Software Engineer | OpenROAD Worldwide Development | Ingres Germany GmbH | Ohmstr. 12 | 63225 Langen | GERMANY | +49 6103 9881 0
--
You received this message because you are subscribed to the Google Groups "OpenROAD Users Mailing List" group.
To post to this group, send email to openroa...@googlegroups.com.
To unsubscribe from this group, send email to openroad-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/openroad-users?hl=en.
Bodo,
Thank you for the reply. This has fixed my problem. I’ll have to remember to use BINARY instead of STRING for future .Net 3.5 applications.
Martin Bloomfield.
This email was received from the INTERNET and scanned by the Government Secure Intranet anti-virus service supplied by Cable&Wireless Worldwide in partnership with MessageLabs. (CCTM Certificate Number 2009/09/0052.) In case of problems, please call your organisation’s IT Helpdesk.
Communications via the GSi may be automatically logged, monitored and/or recorded for legal purposes.
--
You received this message because you are subscribed to the Google Groups "OpenROAD Users Mailing List" group.
To post to this group, send email to openroa...@googlegroups.com.
To unsubscribe from this group, send email to openroad-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/openroad-users?hl=en.
Conversely, for LONG NVARCHAR and LONG VARCHAR SQL types, you should use
the .NET STRING type.
Chris
Bloomfield, Martin (CRD) wrote:
>
> Bodo,
>
> Thank you for the reply. This has fixed my problem. I�ll have to
> remember to use BINARY instead of STRING for future .Net 3.5 applications.
>
> Martin Bloomfield.
>
> *From:* openroa...@googlegroups.com
> [mailto:openroa...@googlegroups.com] *On Behalf Of *Bodo Bergmann
> *Sent:* Thursday, September 08, 2011 4:57 PM
> *To:* openroa...@googlegroups.com
> *Subject:* RE: [openroad-users] ASP.Net BinaryWrite problem of
> AppServer LongByte data
>
> Have you tried to use �BINARY� instead of �STRING� in the
> DeclareAttribute for parameter �document�?
>
> Bodo.
>
> Bodo Bergmann | Sr. Software Engineer | OpenROAD Worldwide Development
> | Ingres Germany GmbH | Ohmstr. 12 | 63225 Langen | GERMANY | +49 6103
> 9881 0
>
> *From:* openroa...@googlegroups.com
> [mailto:openroa...@googlegroups.com] *On Behalf Of *Bloomfield,
> Martin (CRD)
> *Sent:* Thursday, September 08, 2011 5:34 PM
> *To:* openroa...@googlegroups.com
> *Subject:* [openroad-users] ASP.Net BinaryWrite problem of AppServer
> LongByte data
>
> All,
>
> I�m in the process of converting an old ASP.Net (v1.1) application
> into an ASP.Net (v3.5) application. This application uses an OpenROAD
> Application Server to talk to our Ingres (9.2) database. Part of this
> application extracts documents from the database and downloads them to
> the user. Unfortunately, this is resulting in corruption of the
> documents. The documents are stored in the database in LongByte
> columns and returned to the web page using a STRING parameter.
>
> In traditional ASP, I would simply retrieve the document parameter
> from the PDO object and do a Response.BinaryWrite (document) to
> trigger the download.
>
> Under ASP.Net, this does not work. I�ve tried various modifications
> <mailto:martin.b...@hse.gsi.gov.uk>
> Website: www.pesticides.gov.uk <http://www.pesticides.gov.uk/>
> www.hse.gov.uk <http://www.hse.gov.uk/>
>
> P Save a tree... please don't print this e-mail/ unless you really
> need to/
>
> ************************************************************
> The Chemicals Regulation Directorate (CRD) was created on the 1st
> April 2009.
>
> All our email addresses will follow the following format
>
> firstnam...@hse.gsi.gov.uk
> <mailto:firstnam...@hse.gsi.gov.uk>.
> your organisation�s IT Helpdesk.
> Communications via the GSi may be automatically logged, monitored
> and/or recorded for legal purposes.
>
> --
> You received this message because you are subscribed to the Google
> Groups "OpenROAD Users Mailing List" group.
> To post to this group, send email to openroa...@googlegroups.com.
> To unsubscribe from this group, send email to
> openroad-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/openroad-users?hl=en.
>
> ************************************************************
> The Chemicals Regulation Directorate (CRD) was created on the 1st
> April 2009.
> All our email addresses will follow the following format
> firstnam...@hse.gsi.gov.uk
> <mailto:firstnam...@hse.gsi.gov.uk>.
> Email sent to the previous PSD addresses will continue to be delivered
> but please update your mailing lists or contacts as soon as you can to
> reflect the change.
>
> This email may contain sensitive information. Please ensure that you
> refer to our Statement of Service Standards for guidance on secure
> handling of information
>
> The original of this email was scanned for viruses by the Government
> Secure Intranet virus scanning service supplied by Cable&Wireless
> Worldwide in partnership with MessageLabs. (CCTM Certificate Number
> 2009/09/0052.) On leaving the GSi this email was certified virus free.
> Communications via the GSi may be automatically logged, monitored
> and/or recorded for legal purposes.