|
안녕하십니까.
ADOQuery를 가지고 하나의 필드를 Update하려고 합니다.
ADOConnection1객체를 써서 MDB와 연결을 하구여, 먼저 ADOQuery1이 DBGrid1에
table1의 내용을 select하여 뿌립니다. 그 다음 DBGrid1에 있는 각 셀들을
클릭할 때마다 table1의 조회필드를 1씩 update하려고 합니다.
이 update는 ADOQuery2가 하게 됩니다.... ADOQuery2역시 ADOConnection1을
통하여 MDB와 연결을 합니다.
ADOQuery2가 update하는 부분은 아래와 같이 구현하였습니다.
void __fastcall TForm1::UpdateCount(int rec_no_int, int view_count)
{
AnsiString param1 = IntToStr(view_count);
AnsiString param2 = IntToStr(rec_no_int);
ADOQuery2->Close();
ADOQuery2->Parameters->ParamByName("조회횟수")->Value = param1;
ADOQuery2->Parameters->ParamByName("일련번호")->Value = param2;
ADOQuery2->Open();
}
참고로 ADOQuery2의 SQL은
"update table1 set 조회횟수=:조회횟수 where 일련번호=:일련번호"
입니다.
그런데 실행하면 클릭한 첫번째 데이터만 1이 update되고, 그 다음부터는
update가 일어나지 않습니다. 물론 컴파일/실행시 에러도 나지 않구여..
참고로 처음 실행이되자마자 table1은 ADOQuery1에 의해 열립니다.
ADOQuery1에서 select하는 테이블과 ADOQuery2에서 update하는 테이블은
같은 테이블이구여... ADOQuery2의 Object Inspector안의 내용 중
ExecuteOptions의 eoAsyncExecute만 true로 해 줬습니다.
이것땜시... 몇 시간을 헤매고 있는지... ㅜ ㅜ
|