那位遇到过这种问题?怎么解决的
我写了一个带参数的查询,如果Deal_Man传入中文则查询语句截掉一部分,而英文则正常,我想应该是unicode编码的问题,但我的Deal_Man是通过TEdit的值传入的,怎样解决?我用的是ado2.8版本,希望得到大家帮忙!!!!
具体语句:
...
StrSql:='select * from Workflow_operation c where c.bill_num in (';
StrSql:=StrSql+' select distinct a.bill_num from workflow_bill a,workflow_detail_bill b';
StrSql:=StrSql+' where a.bill_num=b.bill_num ';
StrSql:=StrSql+' and b.deal_man like :Deal_Man ';
StrSql:=StrSql+' and a.bill_class like :Bill_Class';
StrSql:=StrSql+' and a.alarm_class like :Alarm_Class';
if (cxDEdtStart_Date_Begin.Text<>'') and (cxDEdtStart_Date_End.Text<>'') then
begin
StrSql:=StrSql+' and a.start_date between :start_date_begin and :start_date_end';
end;
if (cxDEdtComp_Date_Begin.Text<>'') and (cxDEdtComp_Date_End.Text<>'') then
begin
StrSql:=StrSql+' and a.Actual_Comp_date between :Comp_date_begin and :Comp_date_end';
end;
StrSql:=StrSql+' )';
传值:
if Trim(EdtDeal_Man.Text)<>'' then
begin
// ADOQuery1.Parameters.ParamByName('Deal_Man').Value:=Trim(EdtDeal_Man.Text)
DealMan:=Trim(EdtDeal_Man.Text);
ADOQuery1.Parameters.ParamByName('Deal_Man').DataType:=ftString;
ADOQuery1.Parameters.ParamByName('Deal_Man').Value:=DealMan;
end
else
ADOQuery1.Parameters.ParamByName('Deal_Man').Value:='%%';
if Trim(CobBill_Class.Text)<>'' then
ADOQuery1.Parameters.ParamByName('Bill_Class').Value:=Trim(CobBill_Class.Text)
else
ADOQuery1.Parameters.ParamByName('Bill_Class').Value:='%%';
if Trim(CobAlarm_Class.Text)<>'' then
ADOQuery1.Parameters.ParamByName('Alarm_Class').Value:=Trim(CobAlarm_Class.Text)
else
ADOQuery1.Parameters.ParamByName('Alarm_Class').Value:='%%';
if (cxDEdtStart_Date_Begin.Text<>'') and (cxDEdtStart_Date_End.Text<>'') then
begin
ADOQuery1.Parameters.ParamByName('start_date_begin').Value:=cxDEdtStart_Date_Begin.Date;
ADOQuery1.Parameters.ParamByName('start_date_end').Value:=cxDEdtStart_Date_End.Date;
end;
if (cxDEdtComp_Date_Begin.Text<>'') and (cxDEdtComp_Date_End.Text<>'') then
begin
ADOQuery1.Parameters.ParamByName('Comp_date_begin').Value:=cxDEdtComp_Date_Begin.Date;
ADOQuery1.Parameters.ParamByName('Comp_date_end').Value:=cxDEdtComp_Date_End.Date;
end;
在sqlserver时间跟踪器:
传参数‘杨测试’
exec sp_executesql N'select * from Workflow_operation c where c.bill_num in ( select distinct a.bill_num from workflow_bill a,workflow_detail_bill b where a.bill_num=b.bill_num and b.deal_man like @P1 and a.bill_class like @P2 and a.alarm_class like @P3 )
', N'@P1 varchar(3),@P2 varchar(2),@P3 varchar(2)', '杨
传参数‘test’
exec sp_executesql N'select * from Workflow_operation c where c.bill_num in ( select distinct a.bill_num from workflow_bill a,workflow_detail_bill b where a.bill_num=b.bill_num and b.deal_man like @P1 and a.bill_class like @P2 and a.alarm_class like @P3 )
', N'@P1 varchar(4),@P2 varchar(2),@P3 varchar(2)', 'test', '%%', '%%'