I'm having problems saving dates in SQL DB server via C # asp.net, online
I used the asp text box and the asp cascade expander in the ASP file to get the date from the user,
<asp:TextBox runat="server" ID="txt_date"></asp:TextBox> <asp:CalendarExtender runat="server" ID="cal_date" TargetControlID="txt_date"></asp:CalendarExtender>
code after file, suppose the connection and command are declared and initialized,
mycom = new SqlCommand("insert into mytable(dtCol1) values('"+Convert.ToDateTime(txt_dob.Text).ToString("dd-MMM-yyyy") + "')", mycon);mycom.ExecuteNonQuery();
The problem is that when I select a date less than 12 of any month, it works fine, but when the date / day is more than 12 months, it gives an error,
Exception Details: System.FormatException: String was not recognized as a valid DateTime.
I tried all combinations .ToString ("dd-MMM-yyyy")
Please help in advance thanks
Nils source share