I have a form with buttons 'View', 'Save', 'Delete', 'Edit' and some textboxes to input data.. On clicking each buttons the database is connected and the respective action is done. For example clicking on Save button inserts records, clicking on Delete button delete the specified record and clicking on View button the record from database table is fetched etc.
So my question is
1. Should I write the database connectivity code and the corresponding action code repeatedly in each button's click event
or
2. Should I write the database connectivity code once in forms's load event and the action code only in each button's click event. which is better..please suggest.
So my question is
1. Should I write the database connectivity code and the corresponding action code repeatedly in each button's click event
or
2. Should I write the database connectivity code once in forms's load event and the action code only in each button's click event. which is better..please suggest.