PC Review


Reply
Thread Tools Rate Thread

Application/Object reference not set to an instance of an object

 
 
Andrew
Guest
Posts: n/a
 
      8th Aug 2005
Hello,

I'm getting an error in this code.

''' Begin code
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Application("ConnString") = "myString"
End Sub

Public Class Main

Inherits System.Web.UI.Page
Dim myConnection As SqlConnection = New
SqlConnection(Application("ConnString")) '<-- "Object reference not set to
an instance of an object"

...

End Class
''' End code

Not sure why I'm getting this error. Any help is very much appreciated.

Andrew


 
Reply With Quote
 
 
 
 
Andrew
Guest
Posts: n/a
 
      8th Aug 2005
I think I figured this out. I was creating and initializing the variable in
one line of code. C# is fine with this but it seems vb.net didn't care for
it. I moved the init code to the Page_Load() event and it works ok now.

Just in case anyone else runs into that.

Andrew


"Andrew"

> Hello,
>
> I'm getting an error in this code.



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
2nd Chance Exception System.NullReferenceException: Object reference not set to an instance of an object. Abstract Labs Microsoft ASP .NET 1 9th Aug 2007 04:00 PM
Reading Values from FormView Ctrl - Object reference not set to an instance of an object. Prakash Microsoft ASP .NET 0 14th Dec 2006 07:36 AM
Error:operation failed. Erro:Object reference not set to an instance of an object. Raji Microsoft Dot NET 0 3rd Jun 2004 09:03 PM
Server Error in '/' Application. Object reference not set to an instance of an object. Hugo Lara Microsoft Dot NET Framework Forms 3 28th Jan 2004 08:11 PM
Win32_Printer: System.NullReferenceException - Additional information: Object reference not set to an instance of an object. J M Microsoft C# .NET 2 7th Oct 2003 06:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:05 PM.