怎样查询一个含有特殊字符的字段
数据表student中有一个字符型字段un1,它可能是任意的字符,例如' " , ] [ 等;
我在程序中建立查询:
设有CString 类型的变量 str1;(它可能由用户输入也可能直接赋值,其中可能包含一些特殊字符,例如' " 等;
我要建立的查询语句
strSQL="select * from student where un1='" +str1+"'";
但是由于str1中可能包含特殊字符,例如what's this;
这样运行时就可能得到错误的信息;成了select * from student where un1='what's this'
请问如何解决这个问题.