Instantiation class

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Krikelis

    Instantiation class

    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.NullRef erenceException ' occurred in
    namespace.exe

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

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

    public void addRecord(strin g[] a,
    System.Data.Ole Db.OleDbDataAda pter dAdapter,
    System.Data.Dat aSet dataSet, string dtName)
    {

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

    Error is generated at the line specified by -->

    Plese tell me what I am doing wrong
    Thanks.

    Pete

  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Instantiation class

    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.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Peter Krikelis" <anonymous@disc ussions.microso ft.com> wrote in message
    news:0d4401c3a5 4e$21380f20$a40 1280a@phx.gbl.. .[color=blue]
    > 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.NullRef erenceException ' occurred in
    > namespace.exe
    >
    > Additional information: Object reference not set to an
    > instance of an object. "
    >
    > public class myClass()
    > {
    > public myClass(){}
    >
    > public void addRecord(strin g[] a,
    > System.Data.Ole Db.OleDbDataAda pter dAdapter,
    > System.Data.Dat aSet dataSet, string dtName)
    > {
    >
    > --> System.Data.Dat aRow newRo = dataSet.Tables
    > [dtName].NewRow
    > ...
    > }
    > }
    >
    > Error is generated at the line specified by -->
    >
    > Plese tell me what I am doing wrong
    > Thanks.
    >
    > Pete
    >[/color]


    Comment

    Working...