updating database with dataset

  • Thread starter Thread starter Fernanda
  • Start date Start date
F

Fernanda

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.NullReferenceException: Object Reference not
defined for an instance of an object."

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

{

OracleDataAdapter 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 OracleDataAdapter ? I aprecciate very much your
atention.

Fernanda Menks
 
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 OracleDataAdapter and then configure it. After that is
done, then you can call the Update method.

Hope this helps.
 
Fernanda:

You don't have an active instance of the dataadapter...you 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 OracleDataAdapter adapter = new OracleDataAdapter();

it still wouldn't work.

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

HTH,

Bill
 
Back
Top