TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nitol Biswas
NA
173
28.4k
String was not recognized as a valid DateTime.
Dec 29 2016 7:24 AM
This is my code
protected
void
btnUpdate_Click(
object
sender, EventArgs e)
{
DateTime admissionDate = DateTime.ParseExact(txtAddmissionDate.Text,
"dd/MM/yyy y"
, CultureInfo.InvariantCulture);
DateTime examDate = DateTime.ParseExact(txtExamDate.Text,
"dd/MM/yyyy"
, Culture Info.InvariantCulture);
DateTime certificateDate = DateTime.ParseExact(txtCertificateDate.Text,
"dd/MM/ yyyy"
, CultureInfo.InvariantCulture);
SqlConnection cs =
new
SqlConnection(ConfigurationManager.ConnectionStrings[
"tr avelConnectionString"
].ConnectionString);
String str =
"UPDATE [tbl_training_details] SET [service_agent_id] = '"
+ ddlServiceAgentList.SelectedValue +
"',[training_addmission_date] = '"
+ admissionDate +
"',[training_exam_date] = '"
+ examDate +
"',[training_certificate_no] = '"
+ txtCertificateNo.Text +
"',[training_certificate_date] = '"
+ certificateDate +
"',[status_id] = '"
+ ddlStatus.SelectedValue +
"',[comment] = '"
+ txtComment.Text +
"'WHERE [passenger_id] = "
+ txtPassengerName.Text;
SqlCommand sc =
new
SqlCommand(str, cs);
cs.Open();
sc.ExecuteNonQuery();
cs.Close();
}
When I click update button "String was not recognized as a valid DateTime." Error Happen. How Should Fix the problem. Please help.
Thanks
Reply
Answers (
5
)
how to retrieve data from dropdownlist using dropdownlistfor
My ViewBag.JobNo is not working in MVC