Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 Getting problems with vb.net codings..help, Object reference not set to an instance

views
     
TSjai1210
post Jan 18 2006, 08:22 PM, updated 20y ago

Getting Started
**
Junior Member
63 posts

Joined: Mar 2005
From: ss2, petaling jaya


I am getting problems with having an unhandled exception occured when trying to execute my vb.net projects. Anyone know how to solve it??

The following is the exception Details:

System.NullReferenceException: Object reference not set to an instance of an object.
TSjai1210
post Jan 18 2006, 08:25 PM

Getting Started
**
Junior Member
63 posts

Joined: Mar 2005
From: ss2, petaling jaya


following is my codes ....




Public Sub InsertRecord()


Dim strFileName As String = System.IO.Path.GetFileName(File1.PostedFile.FileName)
Dim strDirectoryName As String = C:\Inetpub\wwwroot\....\"

If (Not (File1.PostedFile Is Nothing)) AndAlso (File1.PostedFile.ContentLength > 0) Then
Try
File1.PostedFile.SaveAs(strDirectoryName + strFileName)

Catch ex As Exception
End Try

Else
LblPopUpMsg.Text = "please select a file to upload"
End If

TSjai1210
post Jan 18 2006, 08:28 PM

Getting Started
**
Junior Member
63 posts

Joined: Mar 2005
From: ss2, petaling jaya


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:
Dim strFileName As String = System.IO.Path.GetFileName(File1.PostedFile.FileName)
Dim strDirectoryName As String = "C:\Inetpub\...\"



Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
BadSystem.AddDocument.InsertRecord() in C:\Inetpub\wwwroot\BadSystem\AddDocument.aspx.vb:140
BadSystem.AddDocument.btnSave_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\BadSystem\AddDocument.aspx.vb:71
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()



TSjai1210
post Jan 18 2006, 08:35 PM

Getting Started
**
Junior Member
63 posts

Joined: Mar 2005
From: ss2, petaling jaya


the error is point that the the HTML control input File is not declared as new class.

so how do it to declare new class for the HTML contriol? Following is the codes...can u help me declare new class for it...i really got stucks of this..

Dim strFileName As String = System.IO.Path.GetFileName(File1.PostedFile.FileName)
TSjai1210
post Jan 18 2006, 08:53 PM

Getting Started
**
Junior Member
63 posts

Joined: Mar 2005
From: ss2, petaling jaya


Anyone know how to declare new member for

Dim strFileName As String = System.IO.Path.GetFileName(File1.PostedFile.FileName)
TSjai1210
post Jan 18 2006, 11:47 PM

Getting Started
**
Junior Member
63 posts

Joined: Mar 2005
From: ss2, petaling jaya


I use vb.net for writing my coding...so?

 

Change to:
| Lo-Fi Version
0.1492sec    1.91    6 queries    GZIP Disabled
Time is now: 23rd December 2025 - 09:31 PM