Read from data grid
Hello,
I am writing a windows uplication in which i have to read from database ,(while reading i m sorting it using "select * from tabel order by column").display it in datagrid.Edit the datagrid and reflect back the changes(in the sorted order) to database.
datagrid's readonly property is set to false.
I am able to read from database and display it.Problem is when i try to save it back .it is not allowing it.
My code looks like this
oledbDataAdapter adap;
DataSet ds = new DataSet();
oledbCommandBuilder cmd = new oledbCommandBuilder();
// to fill datagrid
adap = new oledbDataAdapter(select * from table order by column);
adap.Fill(ds);
datagrid1.datasource = ds.Tables[0];
//to reflect changes to database
// this is in another function
cmd.DataAdapter = adap;
adap.Update(ds); //runtime error is occureing in this statement
Is there any property required to make datagrid an editable.
thanking you
watashi
|