데이터 테이블에 datetime
데이터 형식의 열이 있는데이 테이블에서 날짜 값을 삽입하고 싶습니다. 텍스트 테이블에 상자 그러나 나는이 오류가 무엇입니까 :varchar 데이터 형식을 datetime 데이터 형식으로 변환하면 asp.net에서 범위를 벗어나는 값이 발생합니다.
The conversion of a varchar data type to a datetime data type resulted in an out-of-range value
여기 내 코드입니다 : 그것은 prfer_date
에 실패
string prfer_date = txtDT_Particip.Text;
int userId = 0;
string constr = ConfigurationManager.ConnectionStrings["mycon"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("Insert_User"))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@FullName", txtFName.Text.Trim());
cmd.Parameters.AddWithValue("@PreferredDateStart", prfer_date.ToString());
}
}
}
. 귀하의 도움에 감사드립니다
[AddWithValue()를 이미 사용 중지 할 수 있습니까?] (http://blogs.msmvps.com/jcoehoorn/blog/2014/05/12/can-we-stop-using-addwithvalue- 이미 /)를 사용하고'.AddWithValue()'사용을 멈 추면 - 예상치 못한 결과를 초래할 수있다. 결과를 노래하십시오 ... –