title: ADO.NET how to add parameter if I use connection class in a separate file?
body: <p>ADO.NET how to add parameter if I use class in a separate file?</p>
  
  <p>Class:</p>
  
  <pre><code>class SQLconnect
  {
      public static void Sql(string Command_Text)
      {
          string connectionPath =
              "Data Source=USER\\SQLEXPRESS;Initial Catalog=db;Integrated Security=SSPI;";
  
          SqlConnection Connection = new SqlConnection(connectionPath);
  
          Connection.Open();
  
          SqlCommand Command = Connection.CreateCommand();
          Command.CommandText = Command_Text;
          Command.ExecuteNonQuery();
  
          Connection.Close();
      }
  }
  </code></pre>
  
  <p>Parameter:</p>
  
  <pre><code>        SQLconnect.Sql("INSERT INTO [dbo].[work] ([name],[code])VALUES(@name, @code)");
  
          SqlParameter param = new SqlParameter();
          param.ParameterName = "@name";
          param.Value = nameTextBox.Text;
          param.SqlDbType = SqlDbType.Text;
          //   Parameters.Add(param);
  
  
          param = new SqlParameter();
          param.ParameterName = "@code";
          param.Value = codeTextBox.Text;
          param.SqlDbType = SqlDbType.Text;
          //   Parameters.Add(param);
  </code></pre>