delphi中写SQL语句中变量的注意事项

1、procedure TForm1.btn1Click(Sender: TObject);

var
  s: String;
begin
  S := 'select * from TMarketInfo where NO='''+'1''';
  ShowMessage(s);
end;
 
结果显示:select * from  TMarketInfo where NO='1'
 
2、procedure TForm1.btn1Click(Sender: TObject);
var
  s: String;
begin
  S := 'select * from TMarketInfo where NO='+'''1''';
  ShowMessage(s);
end;
结果显示:select * from  TMarketInfo where NO='1'
 
3、procedure TForm1.btn1Click(Sender: TObject);
var
  s: String;
begin
  S := 'select * from TMarketInfo where NO=''+1''';
  ShowMessage(s);
end;
结果显示:select * from  TMarketInfo where NO='+1'
 
4、procedure TForm1.btn1Click(Sender: TObject);
var
  s: String;
begin
  S := 'select * from TMarketInfo where NO='+'1';
  ShowMessage(s);
end;
结果显示:select * from  TMarketInfo where NO=1

 

posted on 2018-12-13 19:22  癫狂编程  阅读(571)  评论(0编辑  收藏  举报

导航

好的代码像粥一样,都是用时间熬出来的