asp to asp.net with block variable not set error

A

amitbadgi

I am getting this error for a file while converting an asp application
to asp.net
Object variable or With block variable not set.
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 where it originated in the code.

Exception Details: System.NullReferenceException: Object variable or
With block variable not set.

Source Error:


Line 166: </tr>
Line 167: <% Dim rs As Object
Line 168: If Not rs.EOF Then
Line 169: Do While Not rs.EOF
Line 170:


Source File: C:\Documents and
Settings\amit\WebSite1\reports\default.aspx Line: 168

Stack Trace:


[NullReferenceException: Object variable or With block variable not
set.]
Microsoft.VisualBasic.CompilerServices.Container..ctor(Object
Instance) +232124
Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack) +142
ASP.default_aspx.__Render__control1(HtmlTextWriter __w, Control
parameterContainer) in C:\Documents and
Settings\amit\WebSite1\reports\default.aspx:168
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
ICollection children) +98
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.Page.Render(HtmlTextWriter writer) +27
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,
ControlAdapter adapter) +53
System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
ControlAdapter adapter) +280
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +24
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+8878


Thanks in advance
 
P

Peter van der Goes

I am getting this error for a file while converting an asp application
to asp.net
Object variable or With block variable not set.
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 where it originated in the code.

Exception Details: System.NullReferenceException: Object variable or
With block variable not set.

Source Error:


Line 166: </tr>
Line 167: <% Dim rs As Object
Line 168: If Not rs.EOF Then
Line 169: Do While Not rs.EOF
Line 170:


Source File: C:\Documents and
Settings\amit\WebSite1\reports\default.aspx Line: 168

(from what you've shown) In line 167 you create a reference to an object of
type Object, but not an actual object. Thus, rs is an empty (null)
reference. In line 168, you attempt to use the null reference to qualify use
of the EOF, which fails because rs does not point to an object.
 
A

amitbadgi

Hello Peter, Thankx for your reply, i wanted to know that since i am
just creating a reference and thus how do i fix it, am i supp to
initialize a value or sthing, please let me know. thankyou
 
P

Peter van der Goes

Hello Peter, Thankx for your reply, i wanted to know that since i am
just creating a reference and thus how do i fix it, am i supp to
initialize a value or sthing, please let me know. thankyou

What is rs supposed to be? I could make a guess that you are trying to
create a recordset and that you are using ADO in your ASP application? The
..NET data access technology is ADO.NET, which does not use recordsets. When
you write:

Dim rs As Object

in VB.NET, you are creating a reference to an object of type Object (Object
being the class that sits at the top of the .NET Framework class hierarchy).
I could simply say that to create an actual object, you would just change
the statement to:

Dim rs as New Object

Then, rs would contain the address of the of the instance. However, that
answer masks the differences between the languages and between ASP and
ASP.NET, and will probably only get you to the "next error".
In VB.NET, as opposed to "classic" VB/VBA, you are dealing with a new,
object oriented programming language with rules that are quite different
from those for VB/VBA.

To convert your current ASP applications properly, you'll need to understand
the new world of .NET and how it differs from older technologies.

Here are several places you can start your research from:

http://msdn.microsoft.com/VBasic/Learning/Migrating/

http://msdn.microsoft.com/library/d...bcon/html/vboriUpgradingFromVisualBasic60.asp

http://support.microsoft.com/default.aspx?scid=kb;en-us;317071

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/techmap_vbnet.asp

http://msdn.microsoft.com/library/d...en-us/dnmscms02/html/cms_2002migrationnet.asp

http://msdn.microsoft.com/library/d...s/dnaspp/html/aspnetmigrissues.asp?frame=true
 

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

Top