dbgrideh 怪事情 请看看(100分)

  • 主题发起人 主题发起人 nydelphi
  • 开始时间 开始时间
N

nydelphi

Unregistered / Unconfirmed
GUEST, unregistred user!
var<br>&nbsp; insert:TADOQuery;<br>&nbsp; begin<br>&nbsp; &nbsp; &nbsp; DM.QCadd.First;<br>&nbsp; &nbsp; &nbsp; insert:=TADOQuery.Create(self);<br>&nbsp; &nbsp; &nbsp; insert.Connection:=dm.Conn;<br>&nbsp; &nbsp; &nbsp; while &nbsp; not &nbsp; DM.QCadd.Eof &nbsp; do<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; if &nbsp; DBGrideh1.SelectedRows.CurrentRowSelected &nbsp; then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; insert.Close;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; insert.ParamCheck:=true;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; insert.SQL.Clear;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; insert.SQL.Add('INSERT &nbsp; INTO &nbsp; jiezhang &nbsp; (memuname)VALUES &nbsp; (:menuname)');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; insert.Parameters.ParamByName('menuname').Value:=DBGrideh1.DataSource.DataSet.fieldbyname('menuname').AsString;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; insert.ExecSQL;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dm.QCadd.Next;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; dm.ADOQuery3.Close;<br>&nbsp; &nbsp; &nbsp; dm.ADOQuery3.SQL.Text:='select * from jiezhang';<br>&nbsp; &nbsp; &nbsp; dm.ADOQuery3.Open;<br><br>if &nbsp; DBGrideh1.SelectedRows.CurrentRowSelected &nbsp; then &nbsp;在什么时候为true啊 <br><br>我用的是ehlib中的 dbgrideh 。<br>dbgrideh.options 多行选择已经为true了 &nbsp;为什么 &nbsp;执行的时候 <br>DBGrideh1.SelectedRows.CurrentRowSelected还是 false.....
 
不知道我的理解有没有错,你想做的是把一个数据集中被选中的行中fieldbyname('menuname')的内容写到另一个表(jiezhang)<br><br>我觉得你没必要这样写<br><br>我建议如下:<br>var<br>&nbsp; i:integer;<br>&nbsp; insert:tadoquery;<br>begin<br>&nbsp; for i:=0 to self.DBGridEh1.SelectedRows.Count-1 do<br>&nbsp; &nbsp; begin &nbsp; <br><br>self.DBGridEh1.DataSource.DataSet.Bookmark :=self.DBGridEh1.SelectedRows.Items;<br>&nbsp; &nbsp; &nbsp; &nbsp; insert.Close;<br>&nbsp; &nbsp; &nbsp; &nbsp; insert.ParamCheck:=true;<br>&nbsp; &nbsp; &nbsp; &nbsp; insert.SQL.Clear;<br>&nbsp; &nbsp; &nbsp; &nbsp; insert.SQL.Add('INSERT &nbsp; INTO &nbsp; jiezhang &nbsp; (memuname)VALUES &nbsp; (:menuname)');<br>&nbsp; &nbsp; &nbsp; &nbsp; insert.Parameters.ParamByName('menuname').Value:=DBGrideh1.DataSource.DataSet.fieldbyname('menuname').AsString;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; insert.ExecSQL;<br><br>&nbsp; &nbsp; end;<br><br><br>end;
 
问题我已经找到办法解决啦 &nbsp;谢谢啦
 
后退
顶部