title: Stored Procedure Not Executing ASP.NET C#
body: <p>I really don't know what to do. Could you please help me?</p>
  
  <p>What I'm trying to do is that when a person watns to modify his data shown at screen taken from the DataBase when they finish modifing they click in a button and that's where the stored procedure comes in a checks if the data was modified it updates but if it isn't modified...well it doesn't modify the DataBase BUT when i run the proyect it just doesn't work.</p>
  
  <p>The funny thing is that the Stored Procedure works at SQLServer but at C# won't. </p>
  
  <p>Here's my code:</p>
  
  <p>Stored Procedure:</p>
  
  <pre><code>    Create Procedure SP_PDF
      (@nombre varchar(50), @tel int, @dir varchar(50), @rfc char(13))
      as
      declare @cont int
      set @cont = 0
      while(@cont &lt; 4)
      Begin
          if((select nombre from cat_cliente where rfc = @rfc) != @nombre)
              Begin
                  update cat_cliente set nombre = @nombre 
              End
          else
              Begin
                  set @cont += 1
              End 
          if((select telefono from cat_cliente where rfc = @rfc) != @tel)
              Begin
                  update cat_cliente set telefono = @tel
              End
          else
              Begin
                  set @cont += 1
              End
          if((select direccion from cat_cliente where rfc = @rfc) != @dir)
              Begin
                  update cat_cliente set direccion = @dir
              End
          else
              Begin
                  set @cont += 1
              End
      End
  </code></pre>
  
  <p>C#:</p>
  
  <pre><code>        String query = "exec SP_PDF @nombre, @tel, @dir, @rfc";
          SqlCommand cmd = new SqlCommand(query, cnx);
          cmd.CommandType = CommandType.StoredProcedure;
          cmd.Parameters.AddWithValue("@nombre", SqlDbType.VarChar).Value = Nombre.Text;
          cmd.Parameters.AddWithValue("@tel", SqlDbType.Int).Value = Telefono.Text;
          cmd.Parameters.AddWithValue("@dir", SqlDbType.VarChar).Value = Direccion.Text;
          cmd.Parameters.AddWithValue("@rfc", SqlDbType.Char).Value = RFC.Text;
  
          SqlDataAdapter adp = new SqlDataAdapter(cmd);
          DataSet set = new DataSet();
  
          try
          {
              cnx.Open();
              cmd.ExecuteNonQuery();
              adp.Fill(set);
              Response.Write("&lt;script&gt;window.alert('¡Funciono!');&lt;/script&gt;");
          }
          catch (Exception ex)
          {
              throw ex;
          }
          finally
          {
              cnx.Close();
          }
  </code></pre>