請教前輩如何把區間分析資料保存到另外一個Table? |
缺席
|
K1086
初階會員 發表:63 回覆:148 積分:42 註冊:2007-04-09 發送簡訊給我 |
[code delphi] procedure TTwn_539KgNum_Fm1.HemisphereButton3Click(Sender: TObject); var STDT,MTDT,ENDT,SQL_A,SB1,SB2:string; begin Total_Qry1.Close; Total_Qry1.SQL.Clear; Total_Qry1.SQL.ADD('Delete from Twn_539KGNUM'); //先刪除暫存檔 Total_Qry1.ExecSQL; STDT:=COPY(DATETOSTR(Date_1.Date),6,5) '/' COPY(DATETOSTR(Date_1.Date),1,4); ENDT:=COPY(DATETOSTR(Date_2.Date),6,5) '/' COPY(DATETOSTR(Date_2.Date),1,4); SQL_A:='SELECT 開獎日期, 干支, 星期, A號, B號, C號, D號, E號, 系數分析 FROM Twn_539_NO'; SQL_A:=SQL_A ' Where 開獎日期 >= ''' STDT ''' AND 開獎日期<= ''' ENDT ''' AND 星期 <> "日" '; TG_Qry.Close; TG_Qry.SQL.Clear; TG_Qry.SQL.Add(SQL_A); TG_Qry.Open; if TG_Qry.RecordCount = 0 Then SHOWMESSAGE('沒有開獎記錄...'); While NOT TG_Qry.Eof do begin Led_G1.Caption:=TG_Qry.FIELDBYNAME('A號').AsString; Led_G2.Caption:=TG_Qry.FIELDBYNAME('B號').AsString; Led_G3.Caption:=TG_Qry.FIELDBYNAME('C號').AsString; Led_G4.Caption:=TG_Qry.FIELDBYNAME('D號').AsString; Led_G5.Caption:=TG_Qry.FIELDBYNAME('E號').AsString; Lab_RS1.Caption:=TG_Qry.FIELDBYNAME('系數分析').AsString; T123_OP01:= Led_G1.Caption; T123_OP02:= Led_G2.Caption; T123_OP03:= Led_G3.Caption; T123_OP04:= Led_G4.Caption; T123_OP05:= Led_G5.Caption; T123_UPDAY:= Lab_Day.Caption; SB1:=COPY((TG_Qry.FIELDBYNAME('干支').AsString),1,1); //抓天干第一數 SB2:=COPY((TG_Qry.FIELDBYNAME('干支').AsString),2,1); //抓天干第二數 if (SB1 = '甲') or (SB1 = '己') then begin Lab_TK.Caption :='38'; end; if (SB1 = '乙') or (SB1 = '庚') then begin Lab_TK.Caption :='27'; end; if (SB1 = '丙') or (SB1 = '辛') then begin Lab_TK.Caption :='16'; end; if (SB1 = '丁') or (SB1 = '壬') then begin Lab_TK.Caption :='05'; end; if (SB1 = '戊') or (SB1 = '癸') then begin Lab_TK.Caption :='46'; end; if (SB2 = '子') or (SB2 = '午') or (SB2 = '卯') or (SB2 = '酉') then begin Lab_TG.Caption :='9362'; end; if (SB2 = '辰') or (SB2 = '戌') or (SB2 = '丑') or (SB2 = '未') then begin Lab_TG.Caption :='5183'; end; if (SB2 = '寅') or (SB2 = '申') or (SB2 = '巳') or (SB2 = '亥') then begin Lab_TG.Caption :='7140'; end; if Table1.Active = False then Table1.Active := True; Table1.Edit; Table1.Append; Table1.FieldByName('開獎日期').AsString := TG_Qry.FieldByName('開獎日期').AsString; Table1.Append; Table1.FieldByName('名稱').AsString := TG_Qry.FieldByName('干支').AsString; Table1.Append; Table1.FieldByName('星期').AsString := TG_Qry.FieldByName('星期').AsString; Table1.Append; Table1.FieldByName('天干數').AsString := Lab_TK.Caption; Table1.Append; Table1.FieldByName('地支數').AsString := Lab_TG.Caption; Table1.Append; Table1.FieldByName('系數分析').AsString := TG_Qry.FieldByName('系數分析').AsString; Table1.Append; Table1.FieldByName('A號').AsString := T123_OP01; Table1.Append; Table1.FieldByName('B號').AsString := T123_OP02; Table1.Append; Table1.FieldByName('C號').AsString := T123_OP03; Table1.Append; Table1.FieldByName('D號').AsString := T123_OP04; Table1.Append; Table1.FieldByName('E號').AsString := T123_OP05; Table1.Post; TG_Qry.Next; end; Table1.Active := true; [/code] ※小弟想把區間分析的資料另存到 Table1 問題是一直無法存入區間所有資料,並秀出 Record Key Deleted ,請教前輩幫忙指導要如何改寫才可以達成,謝謝!!! |
K1086
初階會員 發表:63 回覆:148 積分:42 註冊:2007-04-09 發送簡訊給我 |
[code delphi] procedure TTwn_539KgNum_Fm1.HemisphereButton3Click(Sender: TObject); var STDT,MTDT,ENDT,SQL_A,SB1,SB2:string; begin Total_Qry1.Close; Total_Qry1.SQL.Clear; Total_Qry1.SQL.ADD('Delete from Twn_539KGNUM'); //先刪除暫存檔 Total_Qry1.ExecSQL; STDT:=COPY(DATETOSTR(Date_1.Date),6,5) '/' COPY(DATETOSTR(Date_1.Date),1,4); ENDT:=COPY(DATETOSTR(Date_2.Date),6,5) '/' COPY(DATETOSTR(Date_2.Date),1,4); SQL_A:='SELECT 開獎日期, 干支, 星期, A號, B號, C號, D號, E號, 系數分析 FROM Twn_539_NO'; SQL_A:=SQL_A ' Where 開獎日期 >= ''' STDT ''' AND 開獎日期<= ''' ENDT ''' AND 星期 <> "日" '; TG_Qry.Close; TG_Qry.SQL.Clear; TG_Qry.SQL.Add(SQL_A); TG_Qry.Open; if TG_Qry.RecordCount = 0 Then SHOWMESSAGE('沒有開獎記錄...'); While NOT TG_Qry.Eof do begin Led_G1.Caption:=TG_Qry.FIELDBYNAME('A號').AsString; Led_G2.Caption:=TG_Qry.FIELDBYNAME('B號').AsString; Led_G3.Caption:=TG_Qry.FIELDBYNAME('C號').AsString; Led_G4.Caption:=TG_Qry.FIELDBYNAME('D號').AsString; Led_G5.Caption:=TG_Qry.FIELDBYNAME('E號').AsString; Lab_RS1.Caption:=TG_Qry.FIELDBYNAME('系數分析').AsString; T123_OP01:= Led_G1.Caption; T123_OP02:= Led_G2.Caption; T123_OP03:= Led_G3.Caption; T123_OP04:= Led_G4.Caption; T123_OP05:= Led_G5.Caption; T123_UPDAY:= Lab_Day.Caption; SB1:=COPY((TG_Qry.FIELDBYNAME('干支').AsString),1,2); //抓天干第一數 SB2:=COPY((TG_Qry.FIELDBYNAME('干支').AsString),3,2); //抓天干第二數 if (SB1 = '甲') or (SB1 ='己') then begin Lab_TK.Caption :='38'; end; if (SB1 = '乙') or (SB1 = '庚') then begin Lab_TK.Caption :='27'; end; if (SB1 = '丙') or (SB1 = '辛') then begin Lab_TK.Caption :='16'; end; if (SB1 = '丁') or (SB1 = '壬') then begin Lab_TK.Caption :='05'; end; if (SB1 = '戊') or (SB1 = '癸') then begin Lab_TK.Caption :='46'; end; if (SB2 = '子') or (SB2 = '午') or (SB2 = '卯') or (SB2 = '酉') then begin Lab_TG.Caption :='9362'; end; if (SB2 = '辰') or (SB2 = '戌') or (SB2 = '丑') or (SB2 = '未') then begin Lab_TG.Caption :='5183'; end; if (SB2 = '寅') or (SB2 = '申') or (SB2 = '巳') or (SB2 = '亥') then begin Lab_TG.Caption :='7140'; end; Table1.Append; Table1.FieldByName('開獎日期').AsString := TG_Qry.FieldByName('開獎日期').AsString; Table1.FieldByName('名稱').AsString := TG_Qry.FieldByName('干支').AsString; Table1.FieldByName('星期').AsString := TG_Qry.FieldByName('星期').AsString; Table1.FieldByName('天干數').AsString := Lab_TK.Caption; Table1.FieldByName('地支數').AsString := Lab_TG.Caption; Table1.FieldByName('系數分析').AsString := TG_Qry.FieldByName('系數分析').AsString; Table1.FieldByName('A號').AsString := T123_OP01; Table1.FieldByName('B號').AsString := T123_OP02; Table1.FieldByName('C號').AsString := T123_OP03; Table1.FieldByName('D號').AsString := T123_OP04; Table1.FieldByName('E號').AsString := T123_OP05; Table1.Post; TG_Qry.Next; end; [/code] ● 小弟把程式修改成這樣,就一切OK了 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |