Jasmin01
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.StoredProcedur e;
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?
I have the following code:
conn = "MySqlConnection";
conn.Open();
SqlCommand cmd = new SqlCommand("spDaily", conn);
cmd.CommandType = CommandType.StoredProcedur
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
or just put the code with atleast 10 lines above and below the line which is throwing exception
ASKER
Sorry, it did work, I just forgot to use brackets after the "While" statement. Thanks.
happy to help :)
ASKER
DateTime SentDate = Convert.ToDateTime(rdr["Se
Error: Embedded statement cannot be a declaration or labeled statement.