Datagrid, dataset, update, scroll
-
i wrote this code to delete a record. string STOCKConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ALOHA_PATH + "\\stockcontrol;Extended Properties=dBase IV"; OleDbConnection STOCKConnection = new OleDbConnection(STOCKConnString); string colID; colID= this.dataGrid1[index,0].ToString(); string STOCKUpQuery = "Delete * From STOCK.DBF Where ID=("+colID+")"; OleDbCommand STOCKUpCommand = new OleDbCommand(STOCKUpQuery,STOCKConnection); STOCKConnection.Open(); STOCKUpCommand.ExecuteNonQuery(); STOCKConnection.Close(); this record is deleted from stock.dbf, but i can still see this record in my datagrid1 i want to write a code to update my datagrid, dataset !!!! i wrote this code but it's not a good solution to refill datagrid1, coz datagtid1 is showing the records from the beginning , not from where i deleted the record but the scroll bar location is where i deleted the record !!!!!! string MyConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ALOHA_PATH + "\\stockcontrol;Extended Properties=dBase IV"; OleDbConnection MyOleb = new OleDbConnection(MyConnection); OleDbDataAdapter da= new OleDbDataAdapter("Select * from STOCK.dbf",MyOleb); DataSet dsrefresh = new DataSet(); da.Fill (dsrefresh,"Stock"); dataGrid1.DataSource = dsrefresh.DefaultViewManager; dataGrid1.ReadOnly = true; MyOleb.Close(); Thx