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

  • Thread starter prince -=nore=-
  • Start date
P

prince -=nore=-

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,
 
G

Guest

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top