Wednesday, August 18, 2010

How to refresh Database in C# ?

I have DataSet, BindingSource, TableAdapter.


When I delete row from DataSet it deleted from DataGrid, but not deleted


from Database.


When I delete row from TableAtapter or by SqlCommande it deleted from


DataBase but not deleted from DataGridHow to refresh Database in C# ?
U need to call a datagrid.Update after it is deleted out of hte Grid. Or you need to re-fill the grid after u run the sqlcommand.





I presonaly would create the application/webapp using the ADO.NET disconnected feature. I would create an dataset, datatable and fill the datagrid using a SqlDataAdapter. Then all you need to do is call ';SqlDataAdapter.Fill'; to update the Grid and to delete all you have to do is delete a row (via GUI and programaticly) and call ';SqlDataAdapter.Update'; to delete out of the database.





Enjoy -How to refresh Database in C# ?
this.myTableTableAdapter.Fill(… that code created in your Form1_load


So you should copy and past in your button


example:


private void delete_Click(object sender, EventArgs e)


{


this.myTableTableAdapter.Fil…


}

Report Abuse

No comments:

Post a Comment