var aQuery:TSHQuery; vHost:^THostList; i:integer; begin aQuery:=TSHQuery.Create(nil); with aQuery do begin SQL.Clear; SQL.Add('SELECT * FROM THOSTLIST'); SQL.Add('WHERE MACID NOT IN ('); SQL.Add('SELECT HL.MACID FROM TUSERHOSTS UH'); SQL.Add('LEFT JOIN THOSTLIST HL ON UH.HOSTID=HL.MACID'); SQL.Add(format('WHERE UH.USERID=%d)',[CurID])); SQL.Add('ORDER BY IP_ADDR'); try Open; i:=1; while not eof do begin New(vHost); vHost.hlID:=FieldByName('MacID').AsString; vHost.hlCName:=FieldByName('CName').AsString; vHost.hlServer:=FieldByName('HostName').AsString; vHost.hlIPAddr:=FieldByName('IP_Addr').AsString; vHost.hlMacAddr:=FieldByName('Mac_Addr').AsString; ListBoxHost.Items.Add(format('%d,%s - %s',[i,vHost.hlCName,vHost.hlIPAddr])); HostList.AddObject(vHost.hlID,Pointer(vHost)); Inc(i); Next; end; except end; end; THostList是个结构,把每个结构的指针写到TStrings的Object里,这样写多少都可以了。
str:string;
begin
str := '256个字符'+'256个字符'//这样就不会提示超过256个字符
//str :='大于256个字符',就会提示有错end;
这样说,不知道对你是不是有帮助。
Tsetfile = (sfRead, sfWrite..);
TsetDatabase = (sdQuery, sdUpdate..);
TPower = record
File: Tsetfile;
Edit: TsetDatabase;
end;
aQuery:TSHQuery;
vHost:^THostList;
i:integer;
begin
aQuery:=TSHQuery.Create(nil);
with aQuery do
begin
SQL.Clear;
SQL.Add('SELECT * FROM THOSTLIST');
SQL.Add('WHERE MACID NOT IN (');
SQL.Add('SELECT HL.MACID FROM TUSERHOSTS UH');
SQL.Add('LEFT JOIN THOSTLIST HL ON UH.HOSTID=HL.MACID');
SQL.Add(format('WHERE UH.USERID=%d)',[CurID]));
SQL.Add('ORDER BY IP_ADDR');
try
Open;
i:=1;
while not eof do
begin
New(vHost);
vHost.hlID:=FieldByName('MacID').AsString;
vHost.hlCName:=FieldByName('CName').AsString;
vHost.hlServer:=FieldByName('HostName').AsString;
vHost.hlIPAddr:=FieldByName('IP_Addr').AsString;
vHost.hlMacAddr:=FieldByName('Mac_Addr').AsString;
ListBoxHost.Items.Add(format('%d,%s - %s',[i,vHost.hlCName,vHost.hlIPAddr]));
HostList.AddObject(vHost.hlID,Pointer(vHost));
Inc(i);
Next;
end;
except
end;
end;
THostList是个结构,把每个结构的指针写到TStrings的Object里,这样写多少都可以了。