T
tfs
I have a word file stored in an SQL database and am trying to read and
display on my ASP.Net page. It seems to work OK as far as reading and
displaying on the page, but it is not displaying as a word document,
but as a text with all the garbage characters (formatting, non text
characters).
What am I doing wrong?
<%@ Page Language="VB"
ContentType="text/html" trace="true"
ResponseEncoding="iso-8859-1" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<html>
<head>
<title>Temp display</title>
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Dim sResults As String
Dim ConnectionString as String
=System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_Contour_Server")
Dim objConn as New SqlConnection (ConnectionString)
objConn.Open()
Dim CommandText as String = "select document from
openworx..qadocs"
Dim objCmd as New SqlCommand(CommandText,objConn)
Dim objCommand as SqlCommand = new SqlCommand(CommandText,
objConn)
Dim objDataReader as SqlDataReader = objCommand.ExecuteReader(
_
CommandBehavior.CloseConnection)
Dim arrByteData As Byte()
while (objDataReader.Read() = true)
if(objDataReader(0) is System.DBNull.value) then
exit while
else
Response.Clear()
Response.AddHeader("content-disposition",
"inline;filename=Stuff.doc")
Response.ContentType = "application/msword"
arrByteData =
Ctype(objDataReader(0),Byte())
response.BinaryWrite(arrByteData)
end if
end while
End Sub
</script>
</head>
<body>
</body>
</html>
Thanks,
Tom.
display on my ASP.Net page. It seems to work OK as far as reading and
displaying on the page, but it is not displaying as a word document,
but as a text with all the garbage characters (formatting, non text
characters).
What am I doing wrong?
<%@ Page Language="VB"
ContentType="text/html" trace="true"
ResponseEncoding="iso-8859-1" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<html>
<head>
<title>Temp display</title>
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Dim sResults As String
Dim ConnectionString as String
=System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_Contour_Server")
Dim objConn as New SqlConnection (ConnectionString)
objConn.Open()
Dim CommandText as String = "select document from
openworx..qadocs"
Dim objCmd as New SqlCommand(CommandText,objConn)
Dim objCommand as SqlCommand = new SqlCommand(CommandText,
objConn)
Dim objDataReader as SqlDataReader = objCommand.ExecuteReader(
_
CommandBehavior.CloseConnection)
Dim arrByteData As Byte()
while (objDataReader.Read() = true)
if(objDataReader(0) is System.DBNull.value) then
exit while
else
Response.Clear()
Response.AddHeader("content-disposition",
"inline;filename=Stuff.doc")
Response.ContentType = "application/msword"
arrByteData =
Ctype(objDataReader(0),Byte())
response.BinaryWrite(arrByteData)
end if
end while
End Sub
</script>
</head>
<body>
</body>
</html>
Thanks,
Tom.