I am working on c# application, which reads data from a .csv file and populate our database.
now the .csv file contain the date information in the following format dd/mm/yyyy
such as 22/07/2011
. so when I try adding this value inside our database using ado.net entity framework :-
TextFieldParser parser = new TextFieldParser(@"C:\csv\file01.csv");
parser.TextFieldType = FieldType.Delimited;
parser.SetDelimiters(",");
while (!parser.EndOfData)
{
Employee DBrecord = new Employee();
DBrecord.LeavingDate = DateTime.Parse(CSVfields[49]);
I got the following exception :-
String was not recognized as a valid DateTime.
so can anyone advice on this please , how I can add my date with the following format dd/mm/yyyy
inside the database ?