473,388 Members | 1,322 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,388 software developers and data experts.

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

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
Nov 19 '05 #1
1 938
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.

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Carel Lotz | last post by:
H We have ported our VB 6 application into VB .NET but are still integrating with a few COM + applications written in VB6 running on our application server (Win 2000 Server). We have the proxies...
1
by: vijay | last post by:
Hi I am working on a web application. I have huge form where in I have filled some part of the form and after two hours again I started filling the rest of the form but I got the following error ...
3
by: Marc Tousignant | last post by:
Hi, I'm currently working on a project and my Inetpub folder was on C:\. I shall now run my project on a server, and the path will by D:\. How can you change the main root ?
20
by: J-T | last post by:
We are working on an asp.net application which is a 3-tier application.I was aksed to create a component which monitors a folder and gets the file and pass them to a class library in our business...
12
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. ...
5
by: sajin | last post by:
Hi all, I'am trying to create object of Excel and powerpoint through my VB.Net 2005 application. When user close the excel or powerpoint it's instance remains in the task manager. I used...
9
by: Doug Glancy | last post by:
I got the following code from Francesco Balena's site, for disposing of Com objects: Sub SetNothing(Of T)(ByRef obj As T) ' Dispose of the object if possible If obj IsNot Nothing AndAlso...
9
NeoPa
by: NeoPa | last post by:
In VBA (I expect VB would be similar) controlling another Office Application (Automation) can be done using the following steps : Ensure the Reference (VBA Window / Tools / References) has been...
4
by: oliv | last post by:
Hi, new to .NET, I need some unique var among the whole application in during the whole lifecycle of the webapp. This var is a Boolean : at start time of the webapp, I want this var to be set...
0
by: =?Utf-8?B?SkhhbGV5?= | last post by:
Our system is: IIS Server: dual Intel Xeon 2.80 GHz, 4 GB Ram Windows Server 2003 SP2 IIS 6.0 SQL Server: dual Intel Xeon 2.80 GHz, 4 GB Ram (separate server) Windows Server 2003 SP2 SQL...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.