Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. email ListaEmail = new email();
  2. while …
  3. {
  4. email Email = new email();
  5. Email.email1 = adoDR["email"].ToString();
  6. Email.tipo = adoDR["tipo"].ToString();
  7. ListaEmail.Add(Email);
  8. }
  9.  
  10. email[] ListaEmail = new email[nRegistros];
  11.  
  12. ListaEmail [Cont].email1 = adoDR["email"].ToString();
  13.  
  14. public static email[] Func_RelatorEmail(Guid IdRelator)
  15. {
  16. try
  17. {
  18. string sql = "SELECT Relator_Email.IdRelator, Relator_Email.EmailId, Email.email, Email.tipo, Email.tipoSpecified "
  19. + "FROM Relator_Email INNER JOIN Email ON Relator_Email.EmailId = Email.EmailId "
  20. + "WHERE(Relator_Email.IdRelator='" + IdRelator + "')";
  21.  
  22. string connString = ClsParametros.Conexao;
  23. SqlConnection adoConn = new SqlConnection(connString);
  24. adoConn.Open();
  25. SqlCommand adoCmd = new SqlCommand(sql, adoConn);
  26. SqlDataReader adoDR = adoCmd.ExecuteReader();
  27.  
  28. // contar o numero de registros
  29. int nRegistros = 0;
  30. while (adoDR.Read())
  31. { ++nRegistros; }
  32.  
  33. // criar o objeto com o numero de registros
  34. email[] ListaEmail = new email[nRegistros];
  35.  
  36. if (nRegistros > 0)
  37. {
  38. adoDR.Close();
  39. adoDR = adoCmd.ExecuteReader();
  40.  
  41. int Cont = 0;
  42. while (adoDR.Read())
  43. {
  44. ListaEmail[Cont].email1 = adoDR["email"].ToString();
  45. ListaEmail[Cont].tipo = adoDR["tipo"].ToString();
  46. Cont++;
  47. }
  48. }
  49. adoDR.Close();
  50. adoDR.Dispose();
  51. adoCmd.Dispose();
  52. adoConn.Close();
  53. adoConn.Dispose();
  54.  
  55. return ListaEmail;
  56. }
  57. catch (Exception ex)
  58. {
  59. throw new Exception(ex.Message);
  60. }
  61. finally
  62. {
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement