Guest User

Untitled

a guest
Mar 14th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. List<int> listatel=new List<int>();
  2. int tel = 0;
  3. string usuario = "";
  4.  
  5. SqlDataReader oReader;
  6. SqlConnection cnn = new SqlConnection(CONEXION.STR);
  7. SqlCommand cmd = new SqlCommand("AgregarTelCliente" , cnn);
  8. cmd.CommandType = CommandType.StoredProcedure;
  9. cmd.Parameters.AddWithValue("@usuario",pusuario);
  10. cmd.Parameters.AddWithValue("@tel",telefono);
  11.  
  12.  
  13.  
  14. SqlParameter oRetorno = new SqlParameter("@Retorno", SqlDbType.Int);
  15. oRetorno.Direction = ParameterDirection.ReturnValue;
  16. cmd.Parameters.Add(oRetorno);
  17.  
  18.  
  19. try
  20. {
  21.  
  22. cnn.Open();
  23. oReader = cmd.ExecuteReader();
  24.  
  25. if (oReader.Read()) //cuando ejecuto paso a paso,no llega al if!
  26. {
  27.  
  28. usuario = (string)oReader["usuario"];
  29. tel = (int)oReader["telefonos"];
  30. listatel.Add(tel);
  31. }
  32.  
  33. }
  34. catch (Exception ex)
  35. {
  36. throw ex;
  37. }
  38. finally
  39. {
  40. cnn.Close();
  41. }
Add Comment
Please, Sign In to add comment