H
huysnet
Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下,我想要得到SNAME,他的名称是数据库表名称,现在我没有办法,只有用ADOQUERY的名字和表名称一致才能够动态得到表的名字,请高手指点<br>procedure Tspfrm.dbckup(Sender: TObject);<br>var<br> sid,sname:string;<br>// tmado:tadoquery;<br>begin<br>// Session->GetTableNames<br> with sdata.tmp do<br> begin<br> close;<br> sql.Clear;<br> sid:=dbgrid1.DataSource.DataSet.fieldbyname('typeid').AsString;<br> sname:= dbgrid1.DataSource.DataSet.Name;<br> sql.Add('select * from '+sname+' where parid = '+sid);<br> open;<br> if not isempty then<br> begin<br> //加filter重新书写,并且在lable1.CAPTION 更改<br> dbgrid1.DataSource.DataSet.Filtered:=false;<br> dbgrid1.Tag:=dbgrid1.Tag+1;<br> dbgrid1.DataSource.DataSet.Filter:='parid = '+sid + ' AND leveal = '+inttostr(dbgrid1.Tag);<br> dbgrid1.DataSource.DataSet.Filtered:=true;<br>// dbgrid1.Columns[0].Visible:=false;<br> label1.Caption:=label1.Caption+'/'+Fields[2].Asstring;<br> listbox2.Items.Add(label1.Caption);<br> listbox2.Items.Add(sid);<br> listbox2.Tag:=listbox2.Tag+2;<br>// application.MessageBox(pchar('上一级的名称是:'+Fields[2].Asstring+' !'),pchar(application.title),mb_ok)<br> end else<br> begin<br> //修改菜单弹出<br> application.MessageBox('是最末端的数据','aaa',mb_ok)<br> end;<br> end;<br>end;