delphi给变量赋值不成功
procedureTForm1.Button1Click(Sender:TObject);varS:string;beginclientdataset1.Close;cl...
procedure TForm1.Button1Click(Sender: TObject);
var
S:string;
begin
clientdataset1.Close;
clientdataset1.CommandText:='select pdline_name,t3.serial_number,t1.serial_number SMT_SN,out_process_time from sajet.g_sn_travel t1,sajet.sys_pdline t2,sajet.g_sn_keyparts t3 '
+'where t1.serial_number=t3.item_part_sn and t1.pdline_id=t2.pdline_id and length( item_part_sn) =12 and t1.process_id=''100037'' and '
+'t3.serial_number=:S';
clientdataset1.Params.ParamValues['S']:=trim(edit1.Text);
showmessage(clientdataset1.CommandText);
clientdataset1.Open; 展开
var
S:string;
begin
clientdataset1.Close;
clientdataset1.CommandText:='select pdline_name,t3.serial_number,t1.serial_number SMT_SN,out_process_time from sajet.g_sn_travel t1,sajet.sys_pdline t2,sajet.g_sn_keyparts t3 '
+'where t1.serial_number=t3.item_part_sn and t1.pdline_id=t2.pdline_id and length( item_part_sn) =12 and t1.process_id=''100037'' and '
+'t3.serial_number=:S';
clientdataset1.Params.ParamValues['S']:=trim(edit1.Text);
showmessage(clientdataset1.CommandText);
clientdataset1.Open; 展开
展开全部
procedure TForm1.Button1Click(Sender: TObject);
var
S:string;
begin
clientdataset1.Close;
clientdataset1.CommandText:='select pdline_name,t3.serial_number,t1.serial_number SMT_SN,out_process_time from sajet.g_sn_travel t1,sajet.sys_pdline t2,sajet.g_sn_keyparts t3 '
+'where t1.serial_number=t3.item_part_sn and t1.pdline_id=t2.pdline_id and length( item_part_sn) =12 and t1.process_id=''100037'' and '
+'t3.serial_number='''+trim(edit1.Text)+'''';
showmessage(clientdataset1.CommandText);
clientdataset1.Open;
这样肯定没有问题,还利于调试
var
S:string;
begin
clientdataset1.Close;
clientdataset1.CommandText:='select pdline_name,t3.serial_number,t1.serial_number SMT_SN,out_process_time from sajet.g_sn_travel t1,sajet.sys_pdline t2,sajet.g_sn_keyparts t3 '
+'where t1.serial_number=t3.item_part_sn and t1.pdline_id=t2.pdline_id and length( item_part_sn) =12 and t1.process_id=''100037'' and '
+'t3.serial_number='''+trim(edit1.Text)+'''';
showmessage(clientdataset1.CommandText);
clientdataset1.Open;
这样肯定没有问题,还利于调试
追问
有问题,变量前后加上了双引号
追答
如果serial_number是整数就把引号去掉就可以
我以为serial_number是字符型
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
针对Params赋值时候,并不会马上体现在SQL语句中,而是在执行SQL的时候将这些参数一起提交给数据库,数据库执行处理这些东西,所以你见到的SQL中参数:S是没变的。通常测试这种SQL是否正确是SQL语句本身是否正确,参数类型及值是否正确
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
clientdataset1.Params.ParamValues['S']:=trim(edit1.Text);
改成
clientdataset1.ParamByName('S').AsString:=trim(edit1.Text);
试试
改成
clientdataset1.ParamByName('S').AsString:=trim(edit1.Text);
试试
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询