Ich möchte mich gleich für den Titel entschuldigen, ich weiß er sagt nix über das problem aus, nur ich weiß einfach nicht wie ich es besser beschreiben soll, lest bitte erstmal die Langfassung.
zuerst wird beim Start des Programms der code abgerufen:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49:
| procedure TForm1.stringgrid_refresh(Grid:TStringGrid); var i:integer; begin IF IB_Con_1.Connected=False then IB_Con_1.Connected:=True; IB_Que_1.close; IB_Que_1.SQL.Clear; With Grid as TStringGrid do begin [...] end else IF name='sg_op' then begin i:=0; IB_Que_1.close; IB_Que_1.SQL.Clear; IB_Que_1.SQL.Text:='SELECT * FROM tb_methode ORDER BY id_methode'; IB_Que_1.Open; sg_clean(sg_op); RowCount:=IB_Que_1.RecordCount+1; while not IB_Que_1.Eof do begin inc(i); sg_op.cells[0,i]:=IntToStr(IB_Que_1.FieldByName('id_methode').AsInteger); sg_op.cells[1,i]:=IB_Que_1.FieldByName('opname').AsString; IF (IB_Que_1.FieldByName('link_kl').AsInteger) <> 0 then begin IB_Que_2.close; IB_Que_2.SQL.Clear; IB_Que_2.SQL.Text:='SELECT klinikname, short FROM tb_klinik WHERE id_klinik=:p1'; IB_Que_2.ParamByName('p1').AsInteger:=IB_Que_1.FieldByName('link_kl').AsInteger; IB_Que_2.Open; sg_op.cells[2,i]:=IB_Que_2.FieldByName('klinikname').AsString+' | '+IB_Que_2.FieldByName('short').AsString end ELSE sg_op.cells[2,i]:='Keine Klinik zugewiesen'; IF (IB_Que_1.FieldByName('link_ts').AsInteger) <> 0 then begin IB_Que_2.close; IB_Que_2.SQL.Clear; IB_Que_2.SQL.Text:='SELECT tischname FROM tb_tisch WHERE id_tisch=:p1'; IB_Que_2.ParamByName('p1').AsInteger:=IB_Que_1.FieldByName('link_ts').AsInteger; IB_Que_2.Open; sg_op.cells[3,i]:=IB_Que_2.FieldByName('tischname').AsString end ELSE sg_op.cells[3,i]:='Kein Tisch zugewiesen'; IF (IB_Que_1.FieldByName('link_an').AsInteger) <> 0 then begin IB_Que_2.close; IB_Que_2.SQL.Clear; IB_Que_2.SQL.Text:='SELECT name FROM tb_info_cap WHERE id_info=:p1'; IB_Que_2.ParamByName('p1').AsInteger:=IB_Que_1.FieldByName('link_an').AsInteger; IB_Que_2.Open; sg_op.cells[4,i]:=IB_Que_2.FieldByName('name').AsString end ELSE sg_op.cells[4,i]:='Kein Maßnahme zugewiesen'; IF (IB_Que_1.FieldByName('link_op').AsInteger) <> 0 then begin IB_Que_2.close; IB_Que_2.SQL.Clear; IB_Que_2.SQL.Text:='SELECT name FROM tb_info_cap WHERE id_info=:p1'; IB_Que_2.ParamByName('p1').AsInteger:=IB_Que_1.FieldByName('link_op').AsInteger; IB_Que_2.Open; sg_op.cells[5,i]:=IB_Que_2.FieldByName('name').AsString end ELSE sg_op.cells[5,i]:='Keine Maßnahme zugewiesen'; IB_Que_1.Next; END; n_op.Text:=''; n_cb_kl.Itemindex:=0; n_cb_ts.Itemindex:=0; n_cb_an_info.Itemindex:=0; n_cb_op_info.Itemindex:=0; e_op.Text:=''; e_cb_kl.Itemindex:=0; e_cb_ts.Itemindex:=0; e_cb_an_info.Itemindex:=0; e_cb_op_info.Itemindex:=0; n_op2.Text:=''; ch_op_aendern.Checked:=False; sg_op.cells[0,0]:='OP-ID'; sg_op.cells[1,0]:='OP-Aufgabe'; sg_op.cells[2,0]:='Klinikname'; sg_op.cells[3,0]:='Tischname'; sg_op.cells[4,0]:='Anästhesiemethode'; sg_op.cells[5,0]:='OP-Methode/LANF'; sg_could.cells[0,0]:='OP-ID'; sg_could.cells[1,0]:='OP-Aufgabe'; sg_could.cells[2,0]:='Tischname'; IB_Que_1.close; IB_Que_2.close; end else [...] IF IB_Con_1.Connected=True then IB_Con_1.Connected:=False; end; |
und wenn ich eine Zelle Selecte wird das aufgerufen:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39:
| procedure TForm1.stringgrid_select(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean); VAR toload:string; i,check:Integer; begin check:=0; IF IB_Con_1.Connected=False then IB_Con_1.Connected:=True; With sender as TStringGrid do begin [...] end else IF name='sg_op' then begin IB_Que_1.close; IB_Que_1.SQL.Clear; IB_Que_1.SQL.Text:='SELECT link_small, link_big FROM tb_tisch WHERE id_tisch=:p1'; IB_Que_1.ParamByName('p1').AsInteger:=StrToInt(sg_op.Cells[0,Arow]); IB_Que_1.Open; IF sg_op.Cells[0,1]<>'' then begin n_op2.Text:=sg_op.Cells[1,Arow]; op_nr:=sg_op.Cells[0,Arow]; e_op.Text:=sg_op.Cells[1,Arow]; e_cb_kl.ItemIndex:=0; e_cb_ts.ItemIndex:=0; e_cb_an_info.ItemIndex:=0; e_cb_op_info.ItemIndex:=0; FOR i:=0 to e_cb_kl.Items.Count-2 do if box_kl[i].txt = sg_op.Cells[2,Arow] then e_cb_kl.ItemIndex:=i+1; FOR i:=0 to e_cb_ts.Items.Count-2 do if box_ts[i].txt = sg_op.Cells[3,Arow] then e_cb_ts.ItemIndex:=i+1; FOR i:=0 to e_cb_an_info.Items.Count-2 do if box_an[i].txt = sg_op.Cells[4,Arow] then e_cb_an_info.ItemIndex:=i+1; FOR i:=0 to e_cb_op_info.Items.Count-2 do if box_op[i].txt = sg_op.Cells[5,Arow] then e_cb_op_info.ItemIndex:=i+1;
IF sg_op.Cells[3,Arow]<> 'Kein Tisch zugewiesen' then begin IF FileExists((ExtractFilePath(Application.ExeName)+'Bilder\')+IB_Que_1.FieldByName('link_big').AsString)=TRUE then toload:=(ExtractFilePath(Application.ExeName)+'Bilder\')+IB_Que_1.FieldByName('link_big').AsString else toload:=ExtractFilePath(Application.ExeName)+'Bilder\'+'leer_tisch.JPG' end Else toload:=ExtractFilePath(Application.ExeName)+'Bilder\'+'leer_tisch.JPG'; pic_op.Picture.LoadFromFile(toload); IB_Que_1.close; end; end else [...] IF IB_Con_1.Connected=True then IB_Con_1.Connected:=False; end; |
Nun, was ist das Problem? Wenn ich etwas eingebe und dies an die DB geschickt wird ist danach die Tabelle leer. Ich hab durch testen bemerkt, sobald die Procedure "stringgrid_select" gelaufen ist (und zwar nicht nur bei dieser tabelel, es gibt noch mehr mit ähnlichen aufrufen drum ELSE) dann liefert das erste mal aufrufen der procedure (stringgrid_refresh) eine leere Tabelle, beim zweiten mal aber sind alle Daten da. Ich hab das mit einem button getestet: Klick af Grid->Button(mit aufruf refresh)->leer->button->voll!
Ich denke, das er beim ersten aufruf das grid leert (sg_clean(sg_op)

aber dann sofort EoF sagt und nix anzeigt. NUR warum? warum ist beim ersten mal die SELECT leer beim zweiten mal sofort danach nicht mehr?
Ideen?? Ich wäre sehr verbunden!
EDIT: +grml* als wüsste ich nciht selbst das der titel nicht gut ist... der ist aber auch ned besser! *Preis an den stifte der nen besseren weiß*