Object ref. not set to an instance of an object

  • Thread starter Thread starter Freaky
  • Start date Start date
F

Freaky

hi all,


I get this error, when i try to execute a query in .NET. Also, this
phenomena is not seen at all times; rareyl i get this - and to my
dismay wen i get this error, .NET is actually executing statements in a
different function.

eg: a()
b()

When I get this error in a(), .NET is actually in b(). I dunno how this
is possible.

foll. is the Exception message caught from the function a()

Object reference not set to an instance of an object. at
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
at
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior
behavior)
at <namespace>.<classname>.a()

Can anyone help me out in this.. PLZ ?
 
Hi Freaky,

The exception will bubble to a() if it is not caught in b(), although your
exception message indicates that you are callling ExecuteReader in a(), or
are you perchance doing multi-threading?
 
Hi Morten,

so, do you mean to say that the exception is actually from the function
b() and not from a (). I am not getting you exactly. Can u plz explain
this with depth?

PLZ...i need it ASAP... also i have been trying for finding out an
error in a(), but i am not able to get it...it is ocuuring very rarely.


One more thing is, in a() i execute a five different queries and store
the result(one row is returned everytime) into a 1-D array (each time i
compl. execution of one query, i close the reader, dispose the command
and then continue with the for-loop.) so, is this causing the problem (
i dont think so!).

Also, in b() i do a FTP operation, ie. get the files stored in the
Remote Server. So, when .NET is into this function, i get the error of
"Object ref. not set...".

This is wat exactly is happening...So can u plz suggest me sthng. ( I
hope u understood the problem)

Thx in advance.
 
Well,

private void Parent()
{
try
{
A();
}
catch(Exception ex)
{
...
}
}

private void A()
{
B();
}

private void B()
{
ExecuteReader...
}


It will look like A caused an exception, even if the actual exception was
caused by B, however, if this is the case, your stack trace should
indicate that the exception occured in B()

I'm guessing something or other is not set to an instance of an object in
B(). It is a bit unclear to me if this always occurs when in B() or only
rarely.


Hi Morten,

so, do you mean to say that the exception is actually from the function
b() and not from a (). I am not getting you exactly. Can u plz explain
this with depth?

PLZ...i need it ASAP... also i have been trying for finding out an
error in a(), but i am not able to get it...it is ocuuring very rarely.


One more thing is, in a() i execute a five different queries and store
the result(one row is returned everytime) into a 1-D array (each time i
compl. execution of one query, i close the reader, dispose the command
and then continue with the for-loop.) so, is this causing the problem (
i dont think so!).

Also, in b() i do a FTP operation, ie. get the files stored in the
Remote Server. So, when .NET is into this function, i get the error of
"Object ref. not set...".

This is wat exactly is happening...So can u plz suggest me sthng. ( I
hope u understood the problem)

Thx in advance.
 
I'm sorry, I can't really tell without seeing the code.

Alternately, try the ADONET group
microsoft.public.dotnet.framework.adonet


hi,

My pgm flow as like this:

parent()
{
a();
b();
.
.
}

a() b()
{ {
try{} try{ }

catch{} catch{}
} }


My pgm finishes with a(), and while executin b(), it is giving an
exception. The stackTrace() says, "obj. ref. not set..." at
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
at
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior
behavior)
at <namespace>.<classname>.a()

So Stack trace points to a(), but i cudnt find any null object being
accessed in a(), and strangely i dont get this in a()-- how come?

Thanks
Freak
 
Anyway thx Morten....i've posted there...waiting for sthng. positive.


Morten said:
I'm sorry, I can't really tell without seeing the code.

Alternately, try the ADONET group
microsoft.public.dotnet.framework.adonet


hi,

My pgm flow as like this:

parent()
{
a();
b();
.
.
}

a() b()
{ {
try{} try{ }

catch{} catch{}
} }


My pgm finishes with a(), and while executin b(), it is giving an
exception. The stackTrace() says, "obj. ref. not set..." at
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
at
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior
behavior)
at <namespace>.<classname>.a()

So Stack trace points to a(), but i cudnt find any null object being
accessed in a(), and strangely i dont get this in a()-- how come?

Thanks
Freak
 
Hi morten,

i've sent an email to u explaining my code. Plz see that..n tell me
wats the problem.

Also, this is a rare phenomena...which doesn't occur in my system. It
is occurring only in the target system.

I am not able to simulate the same ..n hence clueless.

thx in advance
 
Back
Top