Hello all, in my app which connects to a database....I have multiple buttons, or places where I need to run a query, im using this to connect and issue a query:
VB Code:
  1. try
  2. {
  3.    //connect to database and run query
  4. }
  5. catch(Exception ex)
  6. {
  7.    MessageBox.Show(ex.Message);
  8. }
In my code it seems im just copying and pasting that in multiple spots, but running a different query, anyone have any ideas on how to optimize this? Maybe create a function to connect and such, but i'm not sure how...any suggestions? Thanks