473,657 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Object reference not set to an instance of an object" problem

I have a page, where I'm retrieving a file location from a database and
outputting it's contents (HTML) onto a web page.
On the aspx page, I have referred to the code behind it using the line
below. This is where I'm getting the "Object reference not set to an
instance.." error
<% response.writef ile(thelink())% >.

The function that line is referring to is below. The record is being
retrieved from the database according to its querystring.

Function thelink() As Object

Dim tow As String

tow = Request.QuerySt ring("tow")

If tow <> "" Then

viewstate("tow" ) = "@" & tow

CmdIncLink.Para meters.Item("@t ow").Value = tow

Dim tow_reader As SqlDataReader

Try

nsqlconnn.Open( )

tow_reader = CmdIncLink.Exec uteReader

Do While tow_reader.Read

Return tow_reader("inc link")

Loop

nsqlconnn.Close ()

Catch ex As Exception

End Try

End If

End Function
Thanks,
--
----------
'prince
Nov 19 '05 #1
2 1627
Is the path a relative webpath, or a physical path (i.e. c:\whatever)?

I'm sure you checked this already but are you sure the function is returning
a string, and not failing? If an exception is thrown or the datareader is
empty, it will be returning nothing. Also, any reason to type it as an
Object and not a String?

"prince -=nore=-" wrote:
I have a page, where I'm retrieving a file location from a database and
outputting it's contents (HTML) onto a web page.
On the aspx page, I have referred to the code behind it using the line
below. This is where I'm getting the "Object reference not set to an
instance.." error
<% response.writef ile(thelink())% >.

The function that line is referring to is below. The record is being
retrieved from the database according to its querystring.

Function thelink() As Object

Dim tow As String

tow = Request.QuerySt ring("tow")

If tow <> "" Then

viewstate("tow" ) = "@" & tow

CmdIncLink.Para meters.Item("@t ow").Value = tow

Dim tow_reader As SqlDataReader

Try

nsqlconnn.Open( )

tow_reader = CmdIncLink.Exec uteReader

Do While tow_reader.Read

Return tow_reader("inc link")

Loop

nsqlconnn.Close ()

Catch ex As Exception

End Try

End If

End Function
Thanks,
--
----------
'prince

Nov 19 '05 #2
I fixed the problem thanks...

--
----------
'prince
"cmay" <cm**@discussio ns.microsoft.co m> wrote in message
news:67******** *************** ***********@mic rosoft.com...
Is the path a relative webpath, or a physical path (i.e. c:\whatever)?

I'm sure you checked this already but are you sure the function is
returning
a string, and not failing? If an exception is thrown or the datareader is
empty, it will be returning nothing. Also, any reason to type it as an
Object and not a String?

"prince -=nore=-" wrote:
I have a page, where I'm retrieving a file location from a database and
outputting it's contents (HTML) onto a web page.
On the aspx page, I have referred to the code behind it using the line
below. This is where I'm getting the "Object reference not set to an
instance.." error
<% response.writef ile(thelink())% >.

The function that line is referring to is below. The record is being
retrieved from the database according to its querystring.

Function thelink() As Object

Dim tow As String

tow = Request.QuerySt ring("tow")

If tow <> "" Then

viewstate("tow" ) = "@" & tow

CmdIncLink.Para meters.Item("@t ow").Value = tow

Dim tow_reader As SqlDataReader

Try

nsqlconnn.Open( )

tow_reader = CmdIncLink.Exec uteReader

Do While tow_reader.Read

Return tow_reader("inc link")

Loop

nsqlconnn.Close ()

Catch ex As Exception

End Try

End If

End Function
Thanks,
--
----------
'prince

Nov 19 '05 #3

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

Similar topics

3
494
by: Kam | last post by:
Hi! When I am trying to drag user controls or any controls from the Toolbox to a form in some of my projects I get a dialog messages: (Microsoft Deployment Environment) "Object reference not set to an instance of an object" Notes that: 1. It's a designer problem, not a reference problem. When I am adding this user control directly to the code it works just fine, but I can't make it
5
6824
by: Tommy Lang | last post by:
Why doesn't the following code work? I get an error at the following line... CardGroup.PropertyCardType = (CardType)0; The error is "Object reference not set to an instance of an object.", which means the object in question have not been initiated. But I have init the object above n this line... public Card CardGroup = new Card; Anybody knows how to resolve this??
3
19704
by: Steve Lutz | last post by:
Hi All, I have a Windows Service that runs well. The service hosts a remote object. The purpose of the object is so that I can "peak" into the service to see what it's doing. I wrote a small Windows Application that connects to the remote object and prints out status information. Everything works fine when I first start the service. However, after some period, when I attempt to connect to the remote object, I get "Requested Service not...
1
2822
by: Chris Magoun | last post by:
I suddenly received an unexpected error in my project. I have been working on this project for some time without this issue. Nothing has changed in the form that caused the exception. A little experimentation shows that I cannot run ANY .NET web project without getting this error: ---------------------------------------------------------------------------- ---- Object reference not set to an instance of an object.
18
28742
by: Microsoft | last post by:
When I try this in my code I alwas get an errormessage: "Object reference not set to an instance of an object" Dim g As System.Drawing.Graphics g.DrawString("Test", New Font("Arial", 12, FontStyle.Bold), Brushes.Black, 0, 0) Why is this? Marc
1
2278
by: Gummy | last post by:
Hello, I've been banging my head against the wall for a few days on this. When I run a page, either in "View in Browser" or I actually build the solution, I occasionally and very randomly get the following message: 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...
2
2973
by: louie.hutzel | last post by:
This JUST started happening, I don't remember changing any code: When I click the submit button on my form, stuff is supposed to happen (which it does correctly) and a result message is posted back to the same page at the top of my form alerting the user that their request has been approved or denied. However, the end result is an error message: Error Message: Object reference not set to an instance of an object.
35
3201
by: Chris | last post by:
Hi, I tried to create a class which must change the propety 'visible' of a <linktag in the masterpage into 'false' when the user is logged. But i get the error: "Object reference not set to an instance of an object" for the line 'If mpg.FindControl("lkred").Visible = True Then'. I couldn't find sofar the solution. Any help would be appreciated ... Thanks
4
2166
by: My Pet Programmer | last post by:
Ok guys, I'm really looking for someone to tell me how bad a hack this is, and if I'm close to where I should be with it. The basic situation is that I have a class which creates a basic calendar control, the only difference is I stole the navigation scheme from Vista (e.g., if you click on the year you zoom out to the months list, then out to the decade, and back in when you click a year, then a month). I ran into some trouble...
0
1979
by: raghudr | last post by:
Hi all, I am coding for displaying a splash screen until a big job is finished.I am getting an exception:only during the first start of the system.Rest all the time it is working fine. Only when i restart the PC my application will be launced by windows services at startup and i get the exception saying:
0
8399
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8312
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7337
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4159
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1622
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.