'select * from table1 where 学号=001' 通过'select * from table1 where 性别=男' 通不过其中学号和性别都是char型的我知道应该这样改'select * from table_stu where 性别='''+'男'+'''';但这是为什么呢???请指教了另外,
m:string;
m:=' where 学号=001';
'select * from table_stu'+m;  通过想同样实现
性别=男 的效果,却总是调不出来请指教了

解决方案 »

  1.   

    或许是将char 当作数字处理,所以才能执行
    而性别='男'则是在数据库里必须这样写的,因为'男'是一个字符串
      

  2.   

    数据库是不是mssqlserver???
    if 是 then 
      在mssqlserver中 如果既可以编码成数字,也可编码成字符串、则可分配任何一种数据类型
      

  3.   

    flp(会说话的哑巴):是mssqlserver但不太明白你的意思?赐教
      

  4.   

    'select * from table_stu where 性别="男"'
      

  5.   

    因为你的查询不是动态传递变量
    'select * from table1 where 性别=''男+''; ->sql 为'select * from table1 where 性别=男' 传递变量
    var tt :string
    'select * from table1 where 性别=+'''+tt+''';->sql为为'select * from table1 where 性别= tt' 
      

  6.   

    'select * from table_stu where 性别='''+'男'+'''';
    =>'select * from table_stu where 性别='+quotedstr('男');
    改写成这样你是否清楚点