怎样用Insert Into插入记录(100分)

  • 主题发起人 主题发起人 hhjjhhjj
  • 开始时间 开始时间
H

hhjjhhjj

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样用Insert Into 插入一个String;
String中可能有(')等符号
 
adoquery1.sql.add('insert into tablename(xh) values(:xh)');
你只要将:xh参数赋值
 
对,提倡使用参数传递值。
 
如果不想用参数的话可以用QuotedStr
adoquery1.sql.Text := 'INSERT INTO TABLENAME(xh) VALUES('+QuotedStr(s)+')'
 
我用的就是传参数的办法,但有是要报:
如:....之前有未闭合的引号...
郁闷!
 
SQL.Add('insert into pninfo (x,y) values(:x,:y)') ;
ParamByName(x).AsString := str1
ParamByName(y).AsString := stt2
 
我的语句在存储过程里有这个报错,写在程序里句没有了!怎么回事?
 
Quotedstr应该就可以了
 
stringReplace(str,'''','''''',[rfReplaceAll]);
即可。
 
str:=stringReplace(str,'''','''''',[rfReplaceAll]);

adoquery1.sql.Text := 'INSERT INTO TABLENAME(xh) VALUES('+QuotedStr(str)+')'
 
在SQL中也是两个单引号表示一个单引号。
 
存储过程中单 「'」 ,程序里双「'」
 
多人接受答案了。
 
后退
顶部