insert datettime problem
-
Hi I have a query which is inserting a value into datetime field in a database. It shows the error: "The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. The statement has been terminated." Any help woudl be great thanks!! DateTime dttimenow = DateTime.Now; dttimenow.ToShortTimeString(); lbtime.Text = dttimenow.ToShortTimeString(); string sttiming = lbtime.Text; SqlCommand insertusername = new SqlCommand("INSERT INTO table(Startdate) VALUES ('" + stdate + "') ", con);
-
Hi I have a query which is inserting a value into datetime field in a database. It shows the error: "The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. The statement has been terminated." Any help woudl be great thanks!! DateTime dttimenow = DateTime.Now; dttimenow.ToShortTimeString(); lbtime.Text = dttimenow.ToShortTimeString(); string sttiming = lbtime.Text; SqlCommand insertusername = new SqlCommand("INSERT INTO table(Startdate) VALUES ('" + stdate + "') ", con);
-
Hi I have a query which is inserting a value into datetime field in a database. It shows the error: "The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. The statement has been terminated." Any help woudl be great thanks!! DateTime dttimenow = DateTime.Now; dttimenow.ToShortTimeString(); lbtime.Text = dttimenow.ToShortTimeString(); string sttiming = lbtime.Text; SqlCommand insertusername = new SqlCommand("INSERT INTO table(Startdate) VALUES ('" + stdate + "') ", con);
Hi, try with the following statement for inserting value into Datetime field string sttiming = DateTime.Parse(DateTime.Today.ToShortDateString(), System.Globalization.CultureInfo.CreateSpecificCulture("en-US").DateTimeFormat) instead of ur DateTime dttimenow = DateTime.Now; dttimenow.ToShortTimeString(); lbtime.Text = dttimenow.ToShortTimeString(); string sttiming = lbtime.Text; code.