title: Trying to use existing code - "call a stored procedure with a parameter in c#", but can't get it working
body: <p>Using the code from <a href="https://stackoverflow.com/questions/7542517/call-a-stored-procedure-with-parameter-in-c-sharp">Call a stored procedure with parameter in c#</a> this article.</p>
  <p>This is my code:</p>
  <pre><code>using (SqlConnection con = new SqlConnection(dc.Con))
  {
      using (SqlCommand cmd = new SqlCommand(&quot;sp_Add_contact&quot;, con))
      {
          cmd.CommandType = CommandType.StoredProcedure;
  
          cmd.Parameters.Add(&quot;@UserName&quot;, SqlDbType.VarChar).Value = userName;
          cmd.Parameters.Add(&quot;@ScrambledPass&quot;, SqlDbType.VarChar).Value = encryptedPass;
  
          con.Open();
          cmd.ExecuteNonQuery();
      }
  }
  </code></pre>
  <p><code>dc</code> in the <code>dc.Con</code> section &quot;does not exist in the current context&quot; and shows an error. How do I fix this? Are there any dependencies or prerequisites I need? I already have using <code>System.Data.SqlClient</code>; <code>System.</code>Data and other basic essentials for this.</p>