1.)Add the command button , rename the caption to UPDATE
2.)Go to Module and declare or add this code "Public Key as Integer" this holds the unique key of the selected records.
3.)Before updating records first thing to do is to SELECT which record you want to update. Double click the listview and then set the event to Listview1_Dbclick and then start coding. "see image below". Analyze the SELECT statement which means that the ID of the record you selected is in listview. first column.
tips (if the unique identifier of the record is in the other column of listview use this statement ex : (" ListView1.SelectedItem.SubItems(1) ") this means that your unique identifier is in the column 2 of lisview.
4.)Go to button update and click and code for the UPDATE statement. Always remember the syntax of string and integer. see the arrows.. and as what you notice that ("Where ID = "& key &" see image below) it is referring to the code SELECT where the veralue of the unique identifier is equal to Key which we declared as integer because our ID is integer.
tips: you can also string if your unique identifier is string. ( KEY as string )
5.) After coding run the program.
Enjoy :)
Part 5 - Deleting data
No comments:
Post a Comment