字符串内的引号—SQL Serevr 的插入(ADO方法)
xxj 2000-03-19 10:26:00 我采用ADO方法,数据集rs,字符串变量ls_content(值为'123456789')
rs.open "insert into temp (content) values(" & chr(34) & ls_content & chr(34) & ")" (其中chr(34)是双引号)
你会发现,报告以下错误:
[Microsoft][ODBC SQL Server Driver][SQL Server]The name '123456789' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted。
上面这段话的意思好象是,认为“1234567789”是列。
也许你会问:
为什么不用单引号括住字符串ls_content呢?是因为我使用了asp的server.htmlencode函数,将ls_content转换了如双引号、<、>,而单引号却没有转换,所以必须用双引号。