473,394 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Blob

CroCrew
564 Expert 512MB
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~

Expand|Select|Wrap|Line Numbers
  1. Imports System.IO
  2. Imports Oracle.DataAccess.Client
  3. Imports Oracle.DataAccess.Types
  4.  
  5. Partial Class _Default
  6.     Inherits System.Web.UI.Page
  7.  
  8.     Sub GetPDF(ByVal IdNumber As Integer)
  9.         Dim con As OracleConnection = New OracleConnection("Data Source=MIB; User ID=web_view; Password=webview;")
  10.         con.Open()
  11.  
  12.         Dim DestinationLoc As String = Server.MapPath("PDF") & "\" & "Data.pdf"
  13.  
  14.         Dim block As String = "SELECT PdfImage FROM PDF WHERE KeyId = " & IdNumber
  15.         Dim cmd As OracleCommand = New OracleCommand()
  16.         cmd.CommandText = block
  17.         cmd.Connection = con
  18.         cmd.CommandType = Data.CommandType.Text
  19.  
  20.         Dim param2 As OracleParameter = cmd.Parameters.Add("blobfromdb", OracleDbType.Blob)
  21.         param2.Direction = Data.ParameterDirection.Output
  22.  
  23.         cmd.ExecuteNonQuery()
  24.  
  25.         Dim byteData As Byte()
  26.         Dim Paramvalue As OracleBlob = cmd.Parameters(0).Value
  27.  
  28.         byteData = CType((Paramvalue.Value), Byte())
  29.  
  30.         Dim ArraySize As Integer = New Integer()
  31.         ArraySize = byteData.GetUpperBound(0)
  32.  
  33.         Dim fs1 As FileStream = New FileStream(DestinationLoc, FileMode.OpenOrCreate, FileAccess.Write)
  34.         fs1.Write(byteData, 0, ArraySize)
  35.         fs1.Close()
  36.  
  37.         Response.Write("Done!")
  38.     End Sub
  39.  
  40.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  41.         GetPDF(23)
  42.     End Sub
  43. End Class
  44.  
Feb 9 '09 #1
5 1468
shweta123
692 Expert 512MB
Hi,

Please check for the value of Paramvalue.Value before using Ctype function for converting the value into byte array. The value of Paramvalue.Value might be Null. Also you can use try and catch in order to get the exception.
Feb 9 '09 #2
CroCrew
564 Expert 512MB
Sorry for not understand but, can you give me an example on what your asking me to do. Thanks~
Feb 9 '09 #3
CroCrew
564 Expert 512MB
The Try and Catch returns:

System.NullReferenceException: Object reference not set to an instance of an object.
Feb 9 '09 #4
shweta123
692 Expert 512MB
Hi,

Please refer to the following example to solve the error you are getting:

http://www.oracle.com/technology/sam...ock/index.html


@CroCrew
Feb 10 '09 #5
CroCrew
564 Expert 512MB
Thanks, I have everything working now.
Feb 10 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Carolyn Longfoot | last post by:
Help! This is driving me crazy... I'm trying to read a BLOB from a db and display it in a browser, like so: $query="SELECT blob from table where blob_id=9"; $result=mysql_query($query);...
3
by: hamvil79 | last post by:
I'm implementig a java web application using MySQL as database. The main function of the application is basically to redistribuite documents. Those documents (PDF, DOC with an average size around...
15
by: Daniel Schuchardt | last post by:
Hi @ all, i'm sure there was a psql-function to transfere my Blob-Data to the server but I can't remember. I have a script like this : UPDATE xy SET z = lo_import('localpath_and_file'); ...
3
by: Carmine | last post by:
I have to add a date column to a db2/zos table with a blob column. Can I rename the blob table to old, create a new table with the date column, then insert/select the data from the old table? ...
0
by: Paul Kennedy | last post by:
I have a situation where I am utilizing code from MSDN to insert XLS files into a Microsoft Access Table in a column of Ole Object using VBA and DAO. That code also provides me with a method to...
1
by: Markusek Peter | last post by:
Hi, I'm using MySQLDriverCS. I've got no problem to store BLOB into database, but I can't get it back(save to file). Problem is with DataTable(returns string:( ) My code: -- DataTable dt = new...
0
by: Biztalk Migration | last post by:
I am new to using BLOB with oracle stored proc. I dont knw how to set the size of the buffer which seems to overflow no matter what i used to pass it. I am getting an error ...
2
by: Vinciz | last post by:
hi guys... im new in java and i would love to learn some of these... basically i got a sample code to retrieve the blob from the mysql. however, i dont really know what to do with these...
9
by: matt | last post by:
hello, im doing my first ASP.NET app that inserts & retrieves files from Oracle (no need for a discussion on *that*!). i learned first-hand of the somewhat awkward technique for inserting...
4
by: skunapareddy | last post by:
I am needing to read a blob from database and pass it to another java program. I researched internet and found a program that reads a file on the client pc and gives bytes, but when I modified the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
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...

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.