function GetStringID(AStr:string):Word;
begin
with srvPooling do
begin
在表TmpSTable 中DescriptionC 欄位的查詢AStr,即'Select StrID from TmpSTable where DescriptionC = AStr);
if 找到 then 函數返回該StrID
else
begin
Query_Data.Append;
Query_Data.FieldByName('StrID').Value:= Query_Data.RecordCount+1;
Query_Data.FieldByName('DescriptionC').Value:= AStr;
Query_Data.FieldByName('DescriptionE').Value:= ' ';
Result:= CNST_KERNELSTRCNT + Query_Data.RecordCount+1;
Query_Data.Post;
end;
end;
end;
begin
with srvPooling do
begin
在表TmpSTable 中DescriptionC 欄位的查詢AStr,即'Select StrID from TmpSTable where DescriptionC = AStr);
if 找到 then 函數返回該StrID
else
begin
Query_Data.Append;
Query_Data.FieldByName('StrID').Value:= Query_Data.RecordCount+1;
Query_Data.FieldByName('DescriptionC').Value:= AStr;
Query_Data.FieldByName('DescriptionE').Value:= ' ';
Result:= CNST_KERNELSTRCNT + Query_Data.RecordCount+1;
Query_Data.Post;
end;
end;
end;
什麼意思??
我的題目是幫我將函數寫完。
var
adoquery:TAdoquery;
begin
adoquery:= TAdoquery.create(nil); with adoquery do
begin
connectionstring:='连接数据库的串';
close;
sql.clear;
sql.text:= 'Select StrID from TmpSTable where DescriptionC = ' + AStr;
open;
if recordcount >0 then
begin
result:= fieldbyname('StrID').asstring;
end
else
begin
Query_Data.Append;
Query_Data.FieldByName('StrID').Value:= Query_Data.RecordCount+1;
Query_Data.FieldByName('DescriptionC').Value:= AStr;
Query_Data.FieldByName('DescriptionE').Value:= ' ';
Result:= CNST_KERNELSTRCNT + Query_Data.RecordCount+1;
Query_Data.Post;
result:= '';
end;
end;
end;