c# How to assign an alphanumeric primary key to a return variable
<p>I'm a noob with Object Oriented Programming and C# in particular.  I'm attending night school to learn C#, but my knowledge level is at the monkey-see-monkey-do level.  I have some code here and some elementary questions:</p>

<hr>

<pre><code>public static String InsertProduct(SqlConnection cnSQL, String strProductDesc, String strProductHS, String strManufacturer)
    {
        SqlCommand cmdSQL;
        Int32 intRetCode = 0;
        String strProductKey;


        if (cnSQL != null)
        {
            cmdSQL = new SqlCommand();
            cmdSQL.Connection = cnSQL;
            cmdSQL.CommandText = "uspInsertProduct";
            cmdSQL.CommandType = CommandType.StoredProcedure;

            cmdSQL.Parameters.Add(new SqlParameter("@ProductDesc", SqlDbType.NVarChar, 250));
            cmdSQL.Parameters["@ProductDesc"].Direction = ParameterDirection.Input;
            cmdSQL.Parameters["@ProductDesc"].Value = strProductDesc;

            ********************************
             Code removed for brevity
            *********************************

            cmdSQL.Parameters.Add(new SqlParameter("@ProductID", SqlDbType.NVarChar, 10));
            cmdSQL.Parameters["@ProductID"].Direction = ParameterDirection.Output;

            try
            {
                cmdSQL.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                intRetCode = -1;
            }
           ************Offending Code Start
           strProductKey = cmdSQL.Parameters["@ProductID"].ToString;
           ************Offend Code End
            cmdSQL.Parameters.Clear();
            cmdSQL.Dispose();
      }
            return strProductKey; 

    }    
</code></pre>

<p>What is returned when I have this statement "cmdSQL.Parameters["@ProductID"].Direction = ParameterDirection.Output;"?  A record number or the actual key?</p>

<p>Assuming the answer is the actual key, how do I construct the variable assignment so I can return it to the calling routine?</p>

<p>Thanks.</p>
