Das Programm ist eine Art Verwaltung von Subnetzen mit den jeweilige Wertenbereichen.
Hier meine Datenstruktur:
Delphi-Quellcode:
type
TOSubnetDetailsData = class
private
//
public
id : String;
ipaddress : String;
device : String;
dhcp_exclude : Integer;
dhcp_mac : String;
site : String;
building : String;
floor : String;
position : String;
vlan : String;
subnetdevice : String;
description : String;
sid : String;
function GetDHCP_ExcludedName: String;
property dhcp_excludedname : String read GetDHCP_ExcludedName;
end;
So lade ich die Daten aus der
DB in das VST
Delphi-Quellcode:
procedure Tfrm_main.SQLDataToVST_SubnetDetails;
var
i : Integer;
SubnetDetailsData : TOSubnetDetailsData;
begin
vst_network_subnetdetails.Clear;
DSData.Close;
DSData.CommandText := 'select network_subnetdetails.id,'+
'network_subnetdetails.ipaddress,'+
'network_subnetdetails.device,'+
'network_subnetdetails.dhcp_exclude,'+
'network_subnetdetails.dhcp_mac,'+
'network_sites.site,'+
'network_subnets.building,'+
'network_subnets.floor,'+
'network_subnets.position,'+
'network_subnets.vlan,'+
'network_subnets.device as subnetdevice,'+
'network_subnetdetails.description,'+
'network_subnetdetails.subnet_id '+
'from network_subnets '+
'inner join network_subnetdetails on network_subnets.id = network_subnetdetails.subnet_id '+
'inner join network_sites on network_subnets.site_id = network_sites.id '+
'order by cast(parsename([ipaddress], 4) as int),'+
'cast(parsename([ipaddress], 3) as int),'+
'cast(parsename([ipaddress], 2) as int),'+
'cast(parsename([ipaddress], 1) as int)';
DSData.Open;
DSData.First;
for i := 0 to DSData.RecordCount - 1 do
begin
SubnetDetailsData := TOSubnetDetailsData.Create;
with SubnetDetailsData do
begin
id := DSData.FieldByName('id').AsString;
ipaddress := DSData.FieldByName('ipaddress').AsString;
device := DSData.FieldByName('device').AsString;
dhcp_exclude := DSData.FieldByName('dhcp_exclude').AsInteger;
dhcp_mac := DSData.FieldByName('dhcp_mac').AsString;
site := DSData.FieldByName('site').AsString;
building := DSData.FieldByName('building').AsString;
floor := DSData.FieldByName('floor').AsString;
position := DSData.FieldByName('position').AsString;
vlan := DSData.FieldByName('vlan').AsString;
subnetdevice := DSData.FieldByName('subnetdevice').AsString;
description := DSData.FieldByName('description').AsString;
sid := DSData.FieldByName('subnet_id').AsString;
end;
vst_network_subnetdetails.AddChild(nil, SubnetDetailsData);
Application.ProcessMessages;
DSData.Next;
end;
DSData.Close;
end;
Die Abfrage gegen die Datenbank geht schnell und das AddChild dauert seine Zeit. Kann ich da noch etwas optimieren?
Die Struktur und die Methoden sind in Anlehnung an das Stammtisch-Video für VST.
Falls das ein normales Verhalten des VST ist, werde ich den View limitieren.
Sven