title: removing form from c# code?
body: <p>I'm extremely new to C# and programming anything except for SQL. I've gotten the below code to happen on a Form and on a button click. If I wanted to just make this run on open, how would I do that? I'm very new to C# as you can tell (just started today learning it but its pretty exciting!)</p>
  
  <pre><code>        using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Data;
      using System.Drawing;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using System.Windows.Forms;
      using Oracle.DataAccess.Client; // ODP.NET Oracle managed provider
      using Oracle.DataAccess.Types;
  
      namespace OraTrigger
      {
          public partial class Form1 : Form
          {
              public Form1()
              {
                  InitializeComponent();
              }
  
              private void button1_Click(object sender, EventArgs e)
              {
                  string oradb = "Data Source=OMP1;User Id=user;Password=pass;";
  
                  OracleConnection conn = new OracleConnection(oradb); // C#
  
          conn.Open();
  
          OracleCommand cmd = new OracleCommand();
          cmd.Connection = conn;
          cmd.CommandText = "SELECT cast(Count(*) as varchar(20)) as trig FROM ZDMSN.TRIGGER_TEST";
          //cmd.CommandType = CommandType.Text;
  
          OracleDataReader dr = cmd.ExecuteReader();
          dr.Read();
  
          int cnt;
          if (int.TryParse(dr.GetString(0), out cnt))
          {
              if (cnt &gt; 0)
              {
                  System.Diagnostics.Process.Start(@"C:\testfile.bat");                    
              }
          }
          cmd.CommandText = "TRUNCATE TABLE ZDMSN.TRIGGER_TEST";
          conn.Dispose();
              }
          }
      }
  </code></pre>