我想实现将数据库的查询结果显示在memo中,以下是代码 var sGetResult : String ; i: integer ;
begin if ComboBox1.ItemIndex=0//若ComboBox1的选项是第一项,则进行 then begin Query2.Close; Query2.SQL.Clear; Query2.SQL.Add('select * from zhongjie');//查找zhongjie表中所有项 Query2.open; begin With Query2 do sGetResult := ' ; First ;
for i:= 0 to Query2.RecordCount - 1 do begin sGetResult := sGetResult + Query2.Fields[0].AsString ;//返回查找中的第一列,并每项相加 memo1.lines.add(sGetResult);//结果显示在memo中 Next ; end; end; end. 为什么我运行能通过,但memo中显示的却是一片空白?是不是逻辑错误,可我实在看不出哪里有错 或者谁写个正确的给我,谢谢! 还有unable to invoke code completion due to errors in source cord 是什么意思?为什么出现了这个提示还能运行通过? 明天过来看
----------------------------------------------
delphi菜鸟
unable to invoke code completion due to errors in source cord 的意思好像是,因来源约束错误导致代码无法执行。 “Query2.SQL.Add('select * from zhongjie');//查找zhongjie表中所有项” 后面好像应有Query2.SQL.prepare;
----------------------------------------------
-
我改造了一下就可以,你在试试!:) delphi 6.0+它自带的DBDEMOS数据库中的biolife.db表运行通过。代码如下: var sGetResult : String ; i: integer ; begin with query1 do begin close; sql.clear; sql.Add('select * from biolife.db'); open; sGetResult:='; first; for i:= 0 to Query1.RecordCount - 1 do begin sGetResult := sGetResult + Query1.Fields[3].AsString ;//返回查找中的第一列,并每项相加 Next ; end; end; memo1.lines.add(sGetResult);//结果显示在memo中
----------------------------------------------
-