Link to home
Start Free TrialLog in
Avatar of Jasmin01
Jasmin01Flag for South Africa

asked on

C# - assigning a dataset datetime object to a datetime field

Hi.

I have the following code:

conn = "MySqlConnection";
            conn.Open();
            SqlCommand cmd = new SqlCommand("spDaily", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            rdr = cmd.ExecuteReader();

            while (rdr.Read())
                DateTime SentDate = rdr["SentDate"];
rdr.Close();

The line in bold is giving me an error.  What should I do to assign the rdr["SentDate'] to a datetime field so that I may do a check to find out if the sent date is not today?
ASKER CERTIFIED SOLUTION
Avatar of sameer_goyal
sameer_goyal
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jasmin01

ASKER

I am getting an error on :
DateTime SentDate = Convert.ToDateTime(rdr["SentDate"]);

Error: Embedded statement cannot be a declaration or labeled statement.
can you put a screen shot of your code for me?

or just put the code with atleast 10 lines above and below the line which is throwing exception
Sorry, it did work, I just forgot to use brackets after the "While" statement.  Thanks.
happy to help :)