首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

使用Parameters.ParamByName方法时 怎么获取sql.text值

2012-07-16 
使用Parameters.ParamByName方法时 如何获取sql.text值向数据库中插入数据代码:Delphi(Pascal) codewith q

使用Parameters.ParamByName方法时 如何获取sql.text值
向数据库中插入数据代码:

Delphi(Pascal) code
      with qry_temp do      begin        Close;        sql.Clear;        sql.Add('insert into db(字段1,字段2,...,字段n) values (:1,:2,...,:n)');        Parameters.ParamByName('1').Value := Trim(edt_1.Text); //edt_1.Text内容为aaa        Parameters.ParamByName('2').Value := Trim(edt_2.Text); //edt_1.Text内容为bbb        ...        Parameters.ParamByName('n').Value := Trim(edt_n.Text); //edt_n.Text内容为xxx        ShowMessage(sql.Text);        ExecSQL;      end;


现在在运行程序时,ShowMessage(sql.Text); 语句执行后,在弹出的对话框中显示的内容是:

insert into db(字段1,字段2,...,字段n) values (:1,:2,...,:n)

请问如何获取传给:1,:2参数值之后的sql.text语句,即调用ShowMessage(sql.Text); 后弹出的对话框中显示类似下面的效果:
insert into db(字段1,字段2,...,字段n) values ('aaa','bbb',...,'xxx')


[解决办法]
sql.Text是参数不被解释的内容,你看不到参数值
[解决办法]
探讨
sql.Text是参数不被解释的内容,你看不到参数值

[解决办法]
写个函数来处理下不就行了吗,将sql.text中的:xxx全部替换成实际的参数值。

[解决办法]
只能使用数据库监控工具来看,大约就是这样子的

select d.dept_name,h.bed_no,o.patient_id,dex.name,operation_desc as operation,null as surgeon,o.operating_date as start_date_time,null as wound_grade 
from operation o,pat_visit v,dept_dict d,pat_master_index dex ,pats_in_hospital h 
where o.operation_code=:V00001 
and (o.patient_id,o.visit_id) not in (select patient_id,visit_id from operation where operation_code=:V00002) 
and o.operating_date >= :V00003 
and o.operating_date < :V00004 
and o.patient_id=v.patient_id 
and o.visit_id=v.visit_id 
and d.dept_code=v.dept_discharge_from(+) 
and o.patient_id=dex.patient_id 
and o.patient_id=h.patient_id(+) 
and o.visit_id=h.visit_id(+) 
order by start_date_time
:V00001 = '88.5701'
:V00002 = '36.0601'
:V00003 = '2012-5-2'
:V00004 = '2012-5-2 23:59:59'

热点排行