Hello Everyone,
I first want to start off with thanks to anyone that helps me out with this problem. With that said let me ask my question.
I am developing a .NET webpage using VB.NET. What I am trying to do with in this webpage is to query an Oracle database table that hold PDF documents in a BLOB container/field. After running my query I want to display the PDF from the query on the page. Below is what I have so far from trying to figure it out myself.
The error that I am currently getting is on line 28: Object reference not set to an instance of an object.
I have hit my wits end on this one. So, if anyone can help out I would be indebted to them.
Again, thanks
CroCrew~
I first want to start off with thanks to anyone that helps me out with this problem. With that said let me ask my question.
I am developing a .NET webpage using VB.NET. What I am trying to do with in this webpage is to query an Oracle database table that hold PDF documents in a BLOB container/field. After running my query I want to display the PDF from the query on the page. Below is what I have so far from trying to figure it out myself.
The error that I am currently getting is on line 28: Object reference not set to an instance of an object.
I have hit my wits end on this one. So, if anyone can help out I would be indebted to them.
Again, thanks
CroCrew~
Code:
Imports System.IO
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types
Partial Class _Default
Inherits System.Web.UI.Page
Sub GetPDF(ByVal IdNumber As Integer)
Dim con As OracleConnection = New OracleConnection("Data Source=MIB; User ID=web_view; Password=webview;")
con.Open()
Dim DestinationLoc As String = Server.MapPath("PDF") & "\" & "Data.pdf"
Dim block As String = "SELECT PdfImage FROM PDF WHERE KeyId = " & IdNumber
Dim cmd As OracleCommand = New OracleCommand()
cmd.CommandText = block
cmd.Connection = con
cmd.CommandType = Data.CommandType.Text
Dim param2 As OracleParameter = cmd.Parameters.Add("blobfromdb", OracleDbType.Blob)
param2.Direction = Data.ParameterDirection.Output
cmd.ExecuteNonQuery()
Dim byteData As Byte()
Dim Paramvalue As OracleBlob = cmd.Parameters(0).Value
byteData = CType((Paramvalue.Value), Byte())
Dim ArraySize As Integer = New Integer()
ArraySize = byteData.GetUpperBound(0)
Dim fs1 As FileStream = New FileStream(DestinationLoc, FileMode.OpenOrCreate, FileAccess.Write)
fs1.Write(byteData, 0, ArraySize)
fs1.Close()
Response.Write("Done!")
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
GetPDF(23)
End Sub
End Class
Comment