私には、クエリとインフォメーションデータベースを持つ.aspxページがあります。このクエリはODBC接続を介して行われ、データテーブルに格納されます。次に、このデータテーブルをラジオボタングループのデータソースとして使用します。Informix ODBCクエリで日付フィールドに時刻が追加される
私の問題は、何らかの理由で時間が「午前12:00:00」として、ラジオボタンに追加されていることです。 informixフィールドは時刻を含まない日付フィールドなので、これは奇妙です。要約でだから私はそれが時間なしでそれを返すWebページの外部でクエリを実行した場合...「2012-06-15」
...私は取得していますと、次のとおりです。「2012年6月15日12 :00:00 AM 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ドライバverのようです。 3.70TC1は正しい:私は日付だけを見る。 –