读书人

delphi字符串拼接解决方案

发布时间: 2012-05-20 16:03:12 作者: rapoo

delphi字符串拼接
qry1.SQL.Add('insert into T_user (id,username,password,count) values ('+id+','''+name+''','''+pwd+''',0)');
id是int类型的,
name,pwd是字符串类型,
哪位大哥帮我看下

[解决办法]
IntToStr(id),用以用Quotedstr()函理引

Delphi(Pascal) code
qry1.SQL.Add('insert into T_user (id,username,password,count) values ('+IntToStr(id)+','+Quotedstr(name)+','+Quotedstr(pwd)+',0)');
[解决办法]
qry1.SQL.Add('insert into T_user (id,username,password,count) values ('+inttostr(id)+','#39+name+#39','#39+pwd+#39',0)');

遇见在字符串中 需要输入单引号,我喜欢用#39代替
[解决办法]
用Quotedstr()函数,最好

读书人网 >.NET

热点推荐