Subject Object reference not set to an instance of an object
Author clemenslinders
LS,

I use a grid to display my data. This all works fine, but as soon as
I try to use the update command, than I get the error: Object
reference not set to an instance of an object. I've read the
Firebird book, but I cannot find my answer there.

I'm using:
-XtraGrid (latest version 2.05) from devex as my datagrid.
-Firebird 1.5
-Windows XP pro

I tried using

ColumnView view = gridControl1.FocusedView as ColumnView;
view.CloseEditor();
view.UpdateCurrentRow();
sqlDataAdapter1.Update(myDataSet, "MyTable");

and

dataAdapter.Update(dataTable);

Both ways give an error and do not update my table.

I have a gridControl1 with 7 columns.

The select statement is:
private void uiButton3_Click(object sender, System.EventArgs e)

{

TableFM.Clear();

fbCommand1.CommandText=@"select
t2.songname,t4.artistname,t3.componersname,t1.titelsong_yesno,t1.rema
rk,t2.songnr,t1.movienr

from songs t2 join artist t4

on t2.artistnumber=t4.artistnr

join componer t3

on t2.componernumber=t3.componernr

join moviemusic t1

on t1.songnumber=t2.songnr

where t1.movienr="+editBox1.Text;

fbDataAdapter1.Fill(TableFM);

}

The DataSource for gridView1=TableFM, the
DataAdapter=fbDataAdapter1, the DataSet=MusicFileDS with the
Argument Tables named TableFM (Connection=fbConnection1)

Because the select statement select values from more than one table
only a select-statement can be generated. So Update, Insert and
Delete statements have to be programmed manually.

To be sure that the problem isn't in the update statement I gave the
update statement the following value:

fbCommand3.CommandText="update songs set songname=\"Ýesterday\"
where songnr=1";

In the Table songs, the field songnr is the primary key and there
are a number of songs listed. So changing the value of the first
songnr to songname=yesterday should not be a problem.



I put my update command in the griedView_RowUpdated event, which
does fire when an update has occured

private void gridView1_RowUpdated(object sender,
DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)

{

//editBox1.Text=fbCommand3.ExecuteNonQuery().ToString();

ColumnView view = gridControl1.FocusedView as ColumnView;

view.CloseEditor();

view.UpdateCurrentRow();

fbDataAdapter1.Update(FilmMuziekDS.Tables["TableFM"]);

//fbDataAdapter1.Update(FilmMuziekDS, "TableFM");// (both these
lines give same error)

}

I get the following error:

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




I also tried: editBox1.Text=fbCommand3.ExecuteNonQuery().ToString();

in stead of the bottom lines. I than get a different error
(Additional information: Connection must valid and open) but it
doesn't help. I even put fbConnection.Open in front of these lines
but the error remained.

Ofcourse I will probably make a mistake somewhere or I'm just not
looking into the right direction.

I would appreciate it if anyone could help me.

Kind regards,


Clemens Linders