SQL Server 데이터베이스의 endDate
열을 highDate
이라는 C#의 저장된 변수와 비교하려고합니다. SQL Server 데이터베이스에서 dateTime을 가져 오는 중
DateTime highDate = new DateTime(2999, 1, 1);
SqlConnection myConnection = new SqlConnection("My connection string");
SqlCommand myCommand = new SqlCommand("My query including endDate_TS", myConnection);
myCommand.Connection.Open();
SqlDataReader myReader = myCommand.ExecuteReader();
while (myReader.Read())
{
DateTime endDate = new DateTime(myReader["endDate_TS"]); //something is wrong here
}
if (endDate > highDate)
{
//do something
}
어떻게 제대로 나는 SQL Server 데이터베이스에서
endDate_TS
을 수용하기 위해 만든
endDate
변수를 포맷합니까?
endDate_TS
은 SQL Server
DATETIME
데이터 유형입니다.
보기 여기 : 당신이 무엇을 http://stackoverflow.com/questions/16634940/how-to-convert-a-sql-date-to-a-datetime – W92
의미합니까 " 뭔가 잘못되었습니다. ", 예외가 발생합니까, 열이 null인지, DB와 비교해보십시오. Null.Value' 변환합니다. – Habib