title: how do you execute a sql command on a button click and then have it populate a dataset?
body: <p>Ok I have a SQL query that I need to run on a button click and then output to a dataset. </p>
  
  <pre><code>public partial class Form1 : Form
  {
      private void Form1_Load(object sender, EventArgs e)
      {
          Assembly.GetExecutingAssembly().GetName().Version.ToString();
          var line = txtLine.Text;
          var serial = txtSerial.Text;
          var station = txtStation.Text;
      }
  
      private void btnGo_Click(object sender, EventArgs e)
      {
          var line = txtLine.Text;
          var serial = txtSerial.Text;
          var station = txtStation.Text;
  
          if (txtLine.Text.Trim().Length == 0)
          {
              MessageBox.Show("Please enter a Line");
          }
          else if (txtSerial.Text.Trim().Length == 0)
          {
              MessageBox.Show("Please enter a Serial");
          }
          else if (txtStation.Text.Trim().Length == 0)
          {
              MessageBox.Show("Please enter a Station");
          }
          else
          {
              //SQL command goes here.
          }
      }
  }
  </code></pre>
  
  <p>I have the SQL command I just need to know how to execute it as a non store procedure and output the data to the dataGridView1 object.</p>