有關於timer和database的問題 |
缺席
|
Teresa_Chang
一般會員 發表:41 回覆:42 積分:16 註冊:2004-05-04 發送簡訊給我 |
以下是我timer內的程式
void __fastcall TForm2::Timer1Timer(TObject *Sender)
{
mSend->Text = count;
String Temp;
String id,x,y;
char inbuff[1024];
DWORD nBytesRead, dwEvent, dwError;
COMSTAT cs;
ClearCommError(hComm,&dwError,&cs);
if (cs.cbInQue > sizeof(inbuff))
{
PurgeComm(hComm, PURGE_RXCLEAR);
return;
}
ReadFile(hComm, inbuff,cs.cbInQue,&nBytesRead,NULL);
inbuff[cs.cbInQue]= '\0';
mReceive->Text = inbuff;
if(count==0)
{
count = count 1;
id = mReceive->Text;
}
else if(count==1)
{
count = count 1;
x = mReceive->Text;
}
else if(count==2)
{
count = count 1;
y = mReceive->Text;
}
else
{
count = 0;
Query1->Close();
Query1->SQL->Clear();
Query1->SQL->Add("insert into location (ID,X_coordinate,Y_coordinate)");
Query1->SQL->Add("values ('" id "','" x "','" y "')");
Query1->ExecSQL();
Query1->Close();
Query1->SQL->Clear();
Query1->SQL->Text = "select *from location";
Query1->Open();
}
} 但是在 Query1->Close();
Query1->SQL->Clear();
Query1->SQL->Text = "select *from location";
Query1->Open();
這部分就會有問題 另外,如果我把這個Form->Hide();以後,
這個timer還會繼續執行嗎?
|
timhuang
尊榮會員 發表:78 回覆:1815 積分:1608 註冊:2002-07-15 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |