쿼리 및 informix 데이터베이스가있는 .aspx 페이지가 있습니다. 이 쿼리는 ODBC 연결을 통해 수행되며 데이터 테이블에 저장됩니다. 그런 다음이 데이터 테이블은 라디오 버튼 그룹의 데이터 소스로 사용됩니다.Informix ODBC 쿼리가 날짜 필드에 시간을 추가합니다.
제 문제는 어떤 이유로 든 라디오 버튼에 시간이 "12:00:00 AM"으로 추가된다는 것입니다. informix 필드가 시간을 포함하지 않는 날짜 필드이기 때문에 이것은 이상합니다. 웹 페이지 외부에서 쿼리를 실행하면 시간이없이 반환됩니다 ... "2012-06-15"
그래서 요약하면 ... "6/15/2012 12 : 00 : 00 오전 다음과 같이 2012년 6월 15일 "
쿼리는"무엇을 내가 원하는 것은 "
"select DATE(attend_date) as attend_date from soar_major_table where major =? and active<>'N'"
생성하는 코드 데이터 테이블 :
string connString;
connString = ConfigurationManager.ConnectionStrings [ "ERP" ].ConnectionString;
OdbcConnection conn = new OdbcConnection ();
conn.ConnectionString = connString;
string sql = "select DATE(attend_date) as attend_date from soar_major_table where major =? and active<>'N' ";
OdbcCommand command = new OdbcCommand ();
command.CommandText = sql;
command.Parameters.Add (new OdbcParameter ("major", major));
command.Connection = conn;
DataTable dt = new DataTable ();
OdbcDataAdapter dataAdapter = new OdbcDataAdapter ();
dataAdapter.SelectCommand = command;
try
{
conn.Open ();
dataAdapter.Fill (dt);
}
finally
{
if (conn != null && conn.State == ConnectionState.Open)
{
command.Dispose ();
dataAdapter.Dispose ();
conn.Close ();
}
}
return dt;
그리고 마지막으로 라디오 btn 그룹의 인구 :
if (dt.Rows.Count > 0)
{
rdoDate.DataSource = dt;
rdoDate.DataTextField = "attend_date";
rdoDate.DataValueField = "attend_date";
rdoDate.DataBind ();
}
귀하의 진단이 맞습니다. 나는'DATE()'로 간단한 SQL 쿼리를 테스트했는데 ODBC 드라이버 버전 인 것 같다. 3.70TC1은 맞습니다. 나는 날짜 만 보았습니다. –