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.6k
How to convert varchar to datetime
Jan 1 2017 5:44 AM
When I try to update the dates "The conversion of a varchar data type to a datetime data type resulted in an out-of-range value" error is occurred. How can I fix this issue.
c# code
------------
SqlConnection cs =
new
SqlConnection(ConfigurationManager.ConnectionStrings[
"travelConnectionString"
].ConnectionString);
String str =
"UPDATE [tbl_training_details] SET [service_agent_id] = '"
+
ddlServiceAgentList.SelectedValue +
"',[training_addmission_date] = '"
+ txtAddmissionDate.Text +
"',[training_exam_date] = '"
+ txtExamDate.Text +
"',[training_certificate_no] = '"
+ txtCertificateNo.Text +
"',[training_certificate_date] = '"
+ txtCertificateDate.Text +
"',[status_id] = '"
+ ddlStatus.SelectedValue +
"',[comment] = '"
+ txtComment.Text +
"'WHERE [passenger_id] = "
+ txtPassengerName.Text;
SqlCommand sc =
new
SqlCommand(str, cs);
cs.Open();
sc.ExecuteNonQuery();
cs.Close();
str value I got from this code is
str =
"UPDATE [tbl_training_details] SET [service_agent_id] = '0',[training_addmission_date] = '29/09/2016',[training_exam_date] = '20/10/2016',[training_certificate_no] = '5rfde',[training_certificate_date] = '2/11/2016',[status_id] = '14',[comment] = '5gfds'WHERE [passenger_id] = 10413"
Thanks
Reply
Answers (
4
)
how to create pagination in asp.net core web api
CRUD Operation using EXT.NET MVC