When I want to insert the date into sql database it shows error
String was not recognized as a valid DateTime
.Please help me out how to insert date into sql server by using mvc franework.
This is the sql table
SELECT TOP 1000 [Id]
,[FirstName]
,[LastName]
,[Email]
,[TelephoneNo]
,[Category]
,[Specifcation]
,[BuyBetweenDatesFrom]
,[BuyBetweenDatesTo]
,[Details]
FROM [Demo].[dbo].[Enquiry]
thsi is the CSHTML Code
@Html.TextBoxFor(x => x.BuyBetweenDatesFrom, new { @placeholder = "Select From Date ", id = "datepickerfrom", @class = "form-control" })
@Html.TextBoxFor(x => x.BuyBetweenDatesTo, new { @placeholder = "Select To Date ", id = "datepicker", @class = "form-control " })
This is the jquery code for datetime picker.
<script>
$(function () {
$("#datepicker").datepicker();
});
</script>
<script>
$(function () {
$("#datepickerfrom").datepicker();
});
</script>
This is the Controller code.
public ActionResult ProductInquiry(Enquirya)
{
Enquiry enquiry = new Enquiry();
enquiry.FirstName=Request.Form["FirstName"];
enquiry.LastName = Request.Form["LastName"];
enquiry.Email=Request.Form["Email"];
enquiry.TelephoneNo = Request.Form["TelephoneNo"];
enquiry.Category=Request.Form["Category"];
enquiry.Specifcation=Request.Form["Specification"];
enquiry.BuyBetweenDatesFrom =Convert.ToDateTime(Request.Form["BuyBetweenDatesFrom"].ToString());
enquiry.BuyBetweenDatesTo =Convert.ToDateTime(Request.Form["BuyBetweenDatesTo"].ToString());