Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to solve this?

C#
while (dao.DataReader.Read())
                       {
                           objemailobject.Add(new EmailObject()
                           {
                            -- To = dao.DataReader["EmailAddress2"].ToStr(),
                             From = dao.DataReader["From"].ToStr(),






                           });
                       }


To is string[] type and i got this from Emailobject and to append it to datareader but when i am appending it to datareader getting the error mentioned

please help me to solve
Posted
Comments
_Asif_ 25-Feb-15 2:08am    
why To is of type string[]?
Samatha Reddy G 25-Feb-15 2:17am    
how you are returning values form this 'dao.DataReader["EmailAddress2"]'

1 solution

your code should be like this
C#
string[] To;
string[] From;
int count = 0;
while (dao.DataReader.Read())
{
   objemailobject.Add(new EmailObject()
   {
       -- To[count] = dao.DataReader["EmailAddress2"].ToString(),
       From[count] = dao.DataReader["From"].ToString(),
    });
    count++;
}

Please let me know.. if you need further details...
 
Share this answer
 
Comments
raxhemanth 25-Feb-15 2:22am    
actually iam geting to address and from address from EmailObject Class(Entity) so i want that values to be appended to datareader whatever iam getting from the database.
raxhemanth 25-Feb-15 2:23am    
and the To values is a string[] type so i need to convert it into string.
manak chand 25-Feb-15 2:30am    
ok.. you can remove these lines from above code
string[] To;
string[] From;
but is To and from are String Arrays.. if yes then above code(my solution) should work..
raxhemanth 25-Feb-15 2:30am    
written the same you suggested invalid intializer member getting
manak chand 25-Feb-15 2:32am    
you need to create instance of objemailobject object and then add record in it..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900