Also so funktioniert der Code. Natürlich sind so alle Spalten fest vorgegeben!
Delphi-Quellcode:
procedure TForm1.bSucheClick(Sender: TObject);
var
ListItem : TlistItem;
begin
Screen.Cursor := crHourGlass;
lfertig.Caption:= '';
lInfo.Caption:='';
Memo1.Lines.Clear;
dbMain.HostName:=SetupForm.edServer.Text; //Server
dbMain.User:=SetupForm.edLogin.Text; //Benutzername
dbMain.Password:=SetupForm.edPassword.Text; //Passwort
dbMain.Database:=SetupForm.edDB.Text; //Name der Datenbank
dbMain.Connected:=True; //Verbindung herstellen
lvAnzeige.Items.Clear;
try
qrMain.SQL.Text :=
'SELECT * ' +
'FROM ' +
'table_ordertracking T,' +
'kundenmg K ' +
'WHERE ' +
'T.Customer_Number=K.Customer_Number ' +
'AND ' +
'T.Customer_Number like ''' + edknr.Text + '''"%" ' +
'AND ' +
'T.Order_Number like ''' + edatnr.Text + '''"%" ' +
'ORDER BY ' +
'T.DPrint;';
qrMain.Open;
qrMain.FieldByName('Order_Type').AsString;
gauge1.Visible:= True;
gauge1.maxvalue := qrMain.recordcount;
lvAnzeige.Items.BeginUpdate;
while not qrMain.Eof do
begin
ListItem := lvAnzeige.Items.Add;
ListItem.Caption:=qrMain.FieldByName('Order_Type').AsString;
ListItem.SubItems.Add(qrMain.FieldByName('Customer_Number').AsString);
ListItem.SubItems.Add(qrMain.FieldByName('Order_Number').AsString);
ListItem.SubItems.Add(FormatDateTime('dd.mm.yyyy hh:mm:ss', qrMain.FieldByName('First_Event').AsDateTime));
ListItem.SubItems.Add(qrMain.FieldByName('DPrint').AsString);
ListItem.SubItems.Add(qrMain.FieldByName('PrePrint').AsString);
ListItem.SubItems.Add(qrMain.FieldByName('Print').AsString);
ListItem.SubItems.Add(qrMain.FieldByName('BMSLogout').AsString);
ListItem.SubItems.Add(qrMain.FieldByName('Count_DPrint').AsString);
ListItem.SubItems.Add(qrMain.FieldByName('CeWe_Batch').AsString);
gauge1.progress := gauge1.progress + 1;
end;
lvAnzeige.Items.EndUpdate;
gauge1.progress := 0;
gauge1.Visible:= false;
finally
dbMain.Connected:=False; //Verbindung trennen
Screen.Cursor := Cursor;
end;
end;