Good afternoon,
My question is that How do I go about editing saved items from a Database to an application.
I am already able to save to a database, however how can you implement that when a data is changed it is also changed back to the database.
For example - FirstName = David
Later on you can then decide to change the same First name to - Sam.
Any help will be appreciated.
Regards.
Loading
Pelumi EluyeraPosted Mar 31, 2015, 8:58 AM
private void UpdateDatabase_Clock (object sender, EventArgs e)
{
DialogResults update;
update = MessageBox.Show ("Are you sure you want to update this record" "Delete Record" , MessageBoxButtons.OKCancel);
if (update == System.Windows.Forms.DialogResults.OK)
{
Try
{ tbl_AppointmentsTableAdapter.update(this.datasetnumber1.TBL_Appointments);
tbl_EngineerTableAdapter.Update (this.datasetNumber1.TBL_Engineers);
_selectedAppointmentRow = null;
}
catch (Exception ex)
{
MessageBox.Show("Unable to delete the record due to the following error; " + ex.Message);
}
}
}
Anurag SarkarPosted Mar 31, 2015, 8:00 AM
Paste the code that you have tried.
Please have a visit on this link
http://www.dotnettutorials.com/tutorials/database/linq-to-sql-add-edit-delete-cs/
https://msdn.microsoft.com/en-us/library/bb399339%28v=vs.110%29.aspx
https://msdn.microsoft.com/en-us/library/vstudio/bb386870%28v=vs.100%29.aspx
Thanks
Rahul BansalPosted Mar 31, 2015, 6:36 AM
for all - without any condition
for single row- use where condition on the basis of primary key column
Note:- Don't try to update the value of primary key column
update tablename set FirstName = Sam where roll_no='101'