title: How to use SQL-Server Stored Procedures?
body: <p>over the past week or so I've been building an ASP site that connects to a Sql-Server 2008 database. I've never used Stored procedures and I was wondering if anyone could give me some guidance on how to create and how to use them within an ASP method. I'm trying to make the code of the website as simple and elegant as possible. Here's the code I'm trying to change into a stored procedure:</p>
  
  <pre><code>    private void ExecuteInsert(string name, string type)
  {
      SqlConnection conn = new SqlConnection(GetConnectionStringHM());
      string sql = "INSERT INTO tblSoftwareTitles (SoftwareName, SoftwareType) VALUES " 
          +"(@SoftwareName,@SoftwareSystemType)";
  
      try
      {
          conn.Open();
          SqlCommand cmd = new SqlCommand(sql, conn);
          SqlParameter[] param = new SqlParameter[2];
          //param[0] = new SqlParameter("@SoftwareID);
          param[0] = new SqlParameter("@SoftwareName", SqlDbType.NVarChar, 200);
          param[1] = new SqlParameter("@SoftwareType", SqlDbType.Int);
  
          param[0].Value = name;
          param[1].Value = type;
  
          for (int i= 0; i &lt; param.Length; i++)
          {
              cmd.Parameters.Add(param[i]);
          }
          cmd.CommandType = CommandType.Text;
          cmd.ExecuteNonQuery();
      }
      catch (System.Data.SqlClient.SqlException ex)
      {
          string msg ="Insert Error:";
          msg += ex.Message;
          throw new Exception(msg);
      }
  
      finally
      {
          conn.Close();
      }
  
      }
  </code></pre>
  
  <p>This is just a Simple insert that takes two parameters from an entry form and inserts them into the database. Any Help with this would be much appreciated as I feel it would be a useful thing to know later on down the line. Thanks in advance!  </p>