我也没有发现,只有借助于一个临时的stringlist然后进行删除了。
要么下载一个增强的控件
要么下载一个增强的控件
解决方案 »
- 送分100分:如何通过一个函数的形参返回字符串。
- 三层应用中一个奇怪的问题!!不知道你遇到过吗??
- 如何实现不同语言的界面切换?
- 就真的没有人会吗?使用delphi7中的Indv的IdUDPClient和IdUDPServer控件!
- 菜鸟的问题
- forgot的散分帖:这里有上海华东理工大学的朋友吗?请进来说两句(上海的朋友也可以)。
- delphi7安装spcomm
- 请问,我初次来到这里,不知道这里是否有讨论 VFP 的地方,请前辈们告知!谢谢!
- Int64的计算结果为什么是负数呢?
- 关于dbedit的小问题。
- 哪位大大虾,用dephi写过类似delphi里的winsight的监视系统消息的工具?请指点一二.....
- 关于数据加密的问题
去这个站点看看
You can always use a DBGrid to display a Query Result, but if you don´t need the overhead of data aware components, you can use the following function to populate a StringGrid with the result of a SQL sentence.
Answer:
Procedure QueryGrid(DBName, Statement: String; Target: TStringGrid; Titles: Boolean);
Var Col, Lin: Integer;
begin
With TQuery.Create(Nil) Do
Try
DatabaseName := DBName;
SQL.Text := Statement;
Open;
If Not IsEmpty Then
Begin
Target.ColCount := FieldCount;
Target.RowCount := RecordCount+ IIF(Titles,1,0);
Target.FixedCols := 0;
Target.FixedRows := IIF(Titles,1,0);
If Titles Then
For Col := 0 To FieldCount-1 Do
Target.Cells[Col,0] := Fields[Col].FieldName;
Lin := 0;
While Not Eof Do
Begin
For Col := 0 To FieldCount-1 Do
Target.Cells[Col,Lin+Target.FixedRows] :=
Fields[Col].AsString;
Next;
Inc(Lin);
End;
End;
Finally
Close;
Free;
End;
end; { QueryGrid }
E-mail:[email protected]