|
Query1->SQL ->Add("SELECT * FROM test.db");
Query1->SQL ->Add("WHERE RegisteDate :from_date BETWEEN :to_time");
Query1->ParamByName("from_time")->Value = DateTimePicker_from->Date;
Query1->ParamByName("to_time")->Value = DateTimePicker_to->Date;
Query1->Open();
.
.
.
골치아프게 하지 마시고 파라메터를 사용하는 것이 좋습니다.
때에 따라서는 DB의 성능향상도 있습니다.
초보자 님이 쓰신 글 :
: TDateTimePicker 컴포넌트 2개를 가지고 선택된 날짜에서
: 등록된 디비의 날짜 사이의 값을 가져오고 싶습니다.
:
: 아래처럼 해봤는데 에러가 나서 어찌 고처야 하는지 모르겠습니다.
:
:
:
: this->Query1->Close();
: this->Query1->SQL->Clear();
: this->Query1->SQL->Add("select * from TEST.db ");
: this->Query1->SQL->Add("where RegisteDate BETWEEN "+ this->DateTimePicker_from->Date.FormatString("yyyy-mm-dd") +" AND " +this->DateTimePicker_to->Date.FormatString("yyyy-mm-dd") + "");
: this->Query1->Prepare();
: if(Query1->Prepared) Query1->Open();
:
: 에러가 납니다.
:
: DB
: [Field] RegisteDate [Type] Date
|