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
好的代码像粥一样,都是用时间熬出来的