Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- email ListaEmail = new email();
- …
- while …
- {
- email Email = new email();
- Email.email1 = adoDR["email"].ToString();
- Email.tipo = adoDR["tipo"].ToString();
- ListaEmail.Add(Email);
- }
- email[] ListaEmail = new email[nRegistros];
- ListaEmail [Cont].email1 = adoDR["email"].ToString();
- public static email[] Func_RelatorEmail(Guid IdRelator)
- {
- try
- {
- string sql = "SELECT Relator_Email.IdRelator, Relator_Email.EmailId, Email.email, Email.tipo, Email.tipoSpecified "
- + "FROM Relator_Email INNER JOIN Email ON Relator_Email.EmailId = Email.EmailId "
- + "WHERE(Relator_Email.IdRelator='" + IdRelator + "')";
- string connString = ClsParametros.Conexao;
- SqlConnection adoConn = new SqlConnection(connString);
- adoConn.Open();
- SqlCommand adoCmd = new SqlCommand(sql, adoConn);
- SqlDataReader adoDR = adoCmd.ExecuteReader();
- // contar o numero de registros
- int nRegistros = 0;
- while (adoDR.Read())
- { ++nRegistros; }
- // criar o objeto com o numero de registros
- email[] ListaEmail = new email[nRegistros];
- if (nRegistros > 0)
- {
- adoDR.Close();
- adoDR = adoCmd.ExecuteReader();
- int Cont = 0;
- while (adoDR.Read())
- {
- ListaEmail[Cont].email1 = adoDR["email"].ToString();
- ListaEmail[Cont].tipo = adoDR["tipo"].ToString();
- Cont++;
- }
- }
- adoDR.Close();
- adoDR.Dispose();
- adoCmd.Dispose();
- adoConn.Close();
- adoConn.Dispose();
- return ListaEmail;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- finally
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement