I am loading data from my database into a DataTable, and one of the columns is a date field.
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString)) { SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "MySP"; cmd.CommandType = CommandType.StoredProcedure; conn.Open(); using (SqlDataReader rdr = cmd.ExecuteReader()) { dt.Load(rdr); } }
I would like to format this column so that instead of containing the full date, it will be formatted as "MM / DD / YYYY".
I tried scrolling every row in the table and changing the cell for that column, but I get an error that the row is not a valid DateTime object.
I tried changing the DateType column to a row, but I get a message stating that I cannot change DateType after populating the table.
How can i do this? It sounds like such a simple thing, but I have so many problems with it.
Steven
source share