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

"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.writefile(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.QueryString("tow")

If tow <> "" Then

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

CmdIncLink.Parameters.Item("@tow").Value = tow

Dim tow_reader As SqlDataReader

Try

nsqlconnn.Open()

tow_reader = CmdIncLink.ExecuteReader

Do While tow_reader.Read

Return tow_reader("inclink")

Loop

nsqlconnn.Close()

Catch ex As Exception

End Try

End If

End Function
Thanks,
--
----------
'prince
Nov 19 '05 #1
2 1607
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.writefile(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.QueryString("tow")

If tow <> "" Then

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

CmdIncLink.Parameters.Item("@tow").Value = tow

Dim tow_reader As SqlDataReader

Try

nsqlconnn.Open()

tow_reader = CmdIncLink.ExecuteReader

Do While tow_reader.Read

Return tow_reader("inclink")

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**@discussions.microsoft.com> wrote in message
news:67**********************************@microsof t.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.writefile(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.QueryString("tow")

If tow <> "" Then

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

CmdIncLink.Parameters.Item("@tow").Value = tow

Dim tow_reader As SqlDataReader

Try

nsqlconnn.Open()

tow_reader = CmdIncLink.ExecuteReader

Do While tow_reader.Read

Return tow_reader("inclink")

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
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...
5
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...
3
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...
1
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...
18
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,...
1
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...
2
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...
35
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...
4
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...
0
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. ...
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...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

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.