首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

delphi字符串拼接解决方案

2012-05-20 
delphi字符串拼接qry1.SQL.Add(insert into T_user (id,username,password,count) values (+id+,+na

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()函数,最好

热点排行