title: C# - How to avoid repeated code of the Sql Connection to all members method
body: <p>In my C# WinForm Application, I had three member of button which designed as <strong>SELECT,INSERT,UPDATE</strong>. Each button read same database table when clicked. When i ready to make the code, I wont like to repeat the code of sql connection and based code such as SqlAdapter, SqlCommand etc.. in all members methods which i given above. So the question is how should avoid that repeated code because its not best coding style.</p>
  
  <pre><code>button_Select_Click(...)
  {
      //sql releated code
      //get data from database and display in some_display_tool_1
  }
  button_Insert_Click(...)
  {
      //sql releated code
      //get data from database and display in some_display_tool_1
  }
  button_Update_Click(...)
  {
     //sql releated code
     //get data from database and display in some_display_tool_1
  }
  </code></pre>
  
  <p>These are present Pseudocode. I would not want whole code from yours. So Please provide me a better idea in the way of PseudoCode. Sorry, please understand my english. </p>
  
  <p>Thanks!!!</p>