Z zgj_gd Unregistered / Unconfirmed GUEST, unregistred user! 2008-03-05 #1 我将ADOQuery1的数据集显示在DBGrid1中。现在想从DBGrid1选择部分记录(可以通过鼠标多选DBGrid1中的记录),存在另一个ADOQuery2中。怎么处理比较好?
Y yanfeng1001 Unregistered / Unconfirmed GUEST, unregistred user! 2008-03-05 #4 可以取出DBGrid1中部分记录的主键存在一个字符串数组中,然后select * from table where 主键 in 字符串数组 到另一个ADOQuery2中
P PING-Delphi Unregistered / Unconfirmed GUEST, unregistred user! 2008-03-05 #5 一个较笨的办法,动态新建一张表,然后将dbgrid被选中的记录加到表里面去,然后用ADOQuery2连接表…………………………
Z zgj_gd Unregistered / Unconfirmed GUEST, unregistred user! 2008-03-05 #6 来自:lixin0117, 时间:2008-3-5 14:14:42, ID:3877710<br>把選擇的記錄抓出插到AdoQuery2 <br><br>如何插到 AdoQuery2 中 ?
来自:lixin0117, 时间:2008-3-5 14:14:42, ID:3877710<br>把選擇的記錄抓出插到AdoQuery2 <br><br>如何插到 AdoQuery2 中 ?
B bbscom Unregistered / Unconfirmed GUEST, unregistred user! 2008-03-07 #7 {=================================================================<br> 功 能: 复制多条记录,添加到另一数据集中<br> 参 数: SetRecord:复制记录数量 SourceData 源数据集 TargetData 目标数据集<br>=================================================================}<br>Procedure CopyReCordN(SetRecord: Integer; SourceData, TargetData: TDataSet);<br>Var<br> aField: Variant;<br> X, Y: Integer;<br>Begin<br> aField := VarArrayCreate([0, SetRecord - 1, 0, SourceData.FieldCount - 1], VarVariant);<br> For X := 0 To SetRecord - 1 Do Begin<br> For Y := 0 To (SourceData.FieldCount - 1) Do<br> aField[X, Y] := SourceData.Fields[Y].Value;<br> SourceData.Next;<br> End;<br><br> For X := 0 To SetRecord - 1 Do Begin<br> TargetData.Append;<br> For Y := 0 To (TargetData.FieldCount - 1) Do<br> TargetData.Fields[Y].Value := aField[X, Y];<br> End;<br> VarClear(aField);<br>End;
{=================================================================<br> 功 能: 复制多条记录,添加到另一数据集中<br> 参 数: SetRecord:复制记录数量 SourceData 源数据集 TargetData 目标数据集<br>=================================================================}<br>Procedure CopyReCordN(SetRecord: Integer; SourceData, TargetData: TDataSet);<br>Var<br> aField: Variant;<br> X, Y: Integer;<br>Begin<br> aField := VarArrayCreate([0, SetRecord - 1, 0, SourceData.FieldCount - 1], VarVariant);<br> For X := 0 To SetRecord - 1 Do Begin<br> For Y := 0 To (SourceData.FieldCount - 1) Do<br> aField[X, Y] := SourceData.Fields[Y].Value;<br> SourceData.Next;<br> End;<br><br> For X := 0 To SetRecord - 1 Do Begin<br> TargetData.Append;<br> For Y := 0 To (TargetData.FieldCount - 1) Do<br> TargetData.Fields[Y].Value := aField[X, Y];<br> End;<br> VarClear(aField);<br>End;