Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
4
Reply
How to convert varchar to datetime
Nitol Biswas
Jan 1 2017 5:44 AM
708
Reply
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
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
4
)
Next Recommended Forum
how to create pagination in asp.net core web api
CRUD Operation using EXT.NET MVC