Should I write database connectivity code each time ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dalaimanoj
    New Member
    • Apr 2007
    • 7

    #1

    Should I write database connectivity code each time ?

    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.
Working...