C# - ExecuteNonQuery isn't executing stored procedure
<p>I am trying to run a stored procedure with parameters as shown below:</p>

<p>Stored procedure:</p>

<pre><code>CREATE PROCEDURE [dbo].[spPurchase]
     @commodityName VARCHAR(10),
     @startdate DATE,  
     @enddate DATE,
     @tonnes FLOAT,
     @lots INT,
     @value FLOAT,
     @ccy VARCHAR(3),
     @clientref VARCHAR(50),
     @clientid INT,
     @userid INT
AS
BEGIN
    ........
    ........
    ........
END
</code></pre>

<p>C# code to execute this stored procedure:</p>

<pre><code>SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["InventoryConnectionString"].ConnectionString);

SqlCommand cmd = new SqlCommand("spPurchase", conn);

cmd.Parameters.Add("@commodityName", SqlDbType.VarChar, 10).Value = ddlMetals.SelectedValue;
cmd.Parameters.Add("@startdate", SqlDbType.Date).Value = startDate.Value;
cmd.Parameters.Add("@enddate", SqlDbType.Date).Value = endDate.Value;
cmd.Parameters.Add("@tonnes", SqlDbType.Float).Value = Convert.ToDouble(tbQuantity.Value);
cmd.Parameters.Add("@lots", SqlDbType.Int).Value = DBNull.Value;
cmd.Parameters.Add("@value", SqlDbType.Float).Value = DBNull.Value;
cmd.Parameters.Add("@ccy", SqlDbType.VarChar, 3).Value = DBNull.Value;
cmd.Parameters.Add("@clientref", SqlDbType.VarChar, 50).Value = "EigerTest";
cmd.Parameters.Add("@clientid", SqlDbType.Int).Value = Convert.ToInt32(Utils.LoggedInUserId);
cmd.Parameters.Add("@userid", SqlDbType.Int).Value = Convert.ToInt32(Utils.LoggedInUsersAccountId);

cmd.CommandType = CommandType.StoredProcedure;

try
{
    conn.Open();
    cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
    throw new Exception(ex.Message, ex);
}
finally
{
    cmd.Connection.Close();
}
</code></pre>

<p>The stored procedure runs fine from SQL Server and the C# code is successfully connecting to the database. However, it is not executing the stored procedure and is not producing any exceptions or errors. </p>

<p>Looking at recent queries in my database, it looks as though my C# code may be just trying to CREATE the stored procedure rather than executing it.</p>

<p>Can anyone see what I am doing wrong?</p>