Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 19th, 2005, 11:08 AM
Authorized User
 
Join Date: Aug 2003
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error message when I try to Insert an Image into a

Here is my code:

  Dim imgStream As Stream = fUpLoadImage.PostedFile.InputStream()
        Dim imgName As String
        Dim imgContentType As String
        Dim imgLen As Int32
        Dim imgbin() As Byte
        Dim imgName2 As String
        Dim imgContentType2 As String
        Dim imgbin2() As Byte
        imgLen = fUpLoadImage.PostedFile.ContentLength
        imgContentType = fUpLoadImage.PostedFile.ContentType

        Dim UserId As String
        Dim PatientId As String
        Dim RecordId As String

        UserId = txtInsertUserId.Text.ToString
        PatientId = txtInsertPatientId.Text.ToString
        RecordId = txtInsertRecordId.Text.ToString


        Dim imgBinaryData(imgLen) As Byte
        Dim n As Int32 = imgStream.Read(imgBinaryData, 0, imgLen)
        imgbin = imgBinaryData

        'Save images to Database
        Dim MyConnection As New OleDbConnection(ConfigurationSettings.AppSettings( "ConnectionString"))

        MyConnection.Open()

        Dim oCMD As New OleDbCommand("INSERT INTO RESOURCE (userid,patientid,recordid,resourcefileimage) VALUES (?,?,?,?)", MyConnection)



Here is my error message;

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

Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 74:
Line 75: Private Sub btnInsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsert.Click
Line 76: Dim imgStream As Stream = fUpLoadImage.PostedFile.InputStream()
Line 77: Dim imgName As String
Line 78: Dim imgContentType As String


Source File: c:\inetpub\wwwroot\ImageRetreival\default.aspx.vb Line: 76

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
   ImageRetreival._default.btnInsert_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\ImageRetreival\default.aspx.vb: 76
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
   System.Web.UI.Page.ProcessRequestMain()


Sanjeet
__________________
Sanjeet





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to insert in image in a header programatically Michael109 Word VBA 2 April 4th, 2007 09:41 AM
Insert Image kuku HTML Code Clinic 2 July 14th, 2005 02:14 AM
How to insert and retrieve image? hlchuah77 SQL Server 2000 3 February 13th, 2005 11:41 AM
Insert Image Using VBA timmaher Excel VBA 1 September 3rd, 2004 10:54 AM
How to insert an image to a table ahmadnajib MySQL 1 August 20th, 2004 01:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.