Instantiation class

  • Thread starter Thread starter Peter Krikelis
  • Start date Start date
P

Peter Krikelis

Hi,

I wrote a class in the same namespase as my whole project
and in few forms I am trying to use methods that are
implemented in that class. In one form it works perfectly
and when I am trying to call methods in other forms this
error is generated:

" An unhandled exception of
type 'System.NullReferenceException' occurred in
namespace.exe

Additional information: Object reference not set to an
instance of an object. "

public class myClass()
{
public myClass(){}

public void addRecord(string[] a,
System.Data.OleDb.OleDbDataAdapter dAdapter,
System.Data.DataSet dataSet, string dtName)
{

--> System.Data.DataRow newRo = dataSet.Tables
[dtName].NewRow
...
}
}

Error is generated at the line specified by -->

Plese tell me what I am doing wrong
Thanks.

Pete
 
Peter,

A number of things can be happening here. First, is the dataSet
variable set to anything? If so, the dtName table exist in the set? If
not, then that could be a place where it is failing.

Hope this helps.
 
Back
Top