updating database with dataset

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

    #1

    updating database with dataset

    Good afternoon,

    I have a function in a remote server which receives a dataset and makes (or
    at least should do) necessary updates. However, Im receiving this error
    message in my client browser interface:

    "Object Reference not defined for an instance of an object.

    Details of execution: System.NullRefe renceException: Object Reference not
    defined for an instance of an object."

    My function is only this:
    public bool UpdateDataSet (DataSet DS)

    {

    OracleDataAdapt er adapter;

    adapter.Update( DS);

    return true;

    }

    So, any good soul could help me to update a data base using a daaset with
    functions update from OracleDataAdapt er ? I aprecciate very much your
    atention.

    Fernanda Menks


  • William Ryan

    #2
    Re: updating database with dataset

    Fernanda:

    You don't have an active instance of the dataadapter...y ou have it declared
    but never initialized.

    In order for it to work, you need to have it scoped so that it can be seen
    from the call to update.

    So on form load you may have adapter.Fill(DS )

    But you probably want to declare it at the module level, and perhaps
    instantiate it at form load before calling fill.

    The way you are doing it, that DataAdapter hasn't been instantiated and as
    such, there's no select/update or anything else associated with it so even
    if you changed it to OracleDataAdapt er adapter = new OracleDataAdapt er();

    it still wouldn't work.

    If you have a DataAdapter control, then just reference
    this.AdapterNam e.UPdate(DS).

    HTH,

    Bill
    "Fernanda" <fernanda@luz-ef.com> wrote in message
    news:OKBGQnLnDH A.1708@TK2MSFTN GP12.phx.gbl...[color=blue]
    > Good afternoon,
    >
    > I have a function in a remote server which receives a dataset and makes[/color]
    (or[color=blue]
    > at least should do) necessary updates. However, Im receiving this error
    > message in my client browser interface:
    >
    > "Object Reference not defined for an instance of an object.
    >
    > Details of execution: System.NullRefe renceException: Object Reference not
    > defined for an instance of an object."
    >
    > My function is only this:
    > public bool UpdateDataSet (DataSet DS)
    >
    > {
    >
    > OracleDataAdapt er adapter;
    >
    > adapter.Update( DS);
    >
    > return true;
    >
    > }
    >
    > So, any good soul could help me to update a data base using a daaset with
    > functions update from OracleDataAdapt er ? I aprecciate very much your
    > atention.
    >
    > Fernanda Menks
    >
    >[/color]


    Comment

    • Nicholas Paldino [.NET/C# MVP]

      #3
      Re: updating database with dataset

      Fernanda,

      The reason it does not work is because the adapter variable is null, as
      it is not assigned to, only declared. Basically, you should create an
      instance of the OracleDataAdapt er and then configure it. After that is
      done, then you can call the Update method.

      Hope this helps.


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

      "Fernanda" <fernanda@luz-ef.com> wrote in message
      news:OKBGQnLnDH A.1708@TK2MSFTN GP12.phx.gbl...[color=blue]
      > Good afternoon,
      >
      > I have a function in a remote server which receives a dataset and makes[/color]
      (or[color=blue]
      > at least should do) necessary updates. However, Im receiving this error
      > message in my client browser interface:
      >
      > "Object Reference not defined for an instance of an object.
      >
      > Details of execution: System.NullRefe renceException: Object Reference not
      > defined for an instance of an object."
      >
      > My function is only this:
      > public bool UpdateDataSet (DataSet DS)
      >
      > {
      >
      > OracleDataAdapt er adapter;
      >
      > adapter.Update( DS);
      >
      > return true;
      >
      > }
      >
      > So, any good soul could help me to update a data base using a daaset with
      > functions update from OracleDataAdapt er ? I aprecciate very much your
      > atention.
      >
      > Fernanda Menks
      >
      >[/color]


      Comment

      Working...