我的程序中有这么一行代码:
String sql="select * from table2 where 分院 = '" & department & "' ";  
其中   
   分院  为数据库中一表的列名,数据类型是char;
   department  为string    
编译时告诉我类型不匹配

解决方案 »

  1.   

    String sql="select * from table2 where 分院 = '" & department & "' ";  在java能行吗?
    应是这样吧。
    String sql="select * from table2 where 分院 = '" + department ;  
    试试
      

  2.   

    String sql="select * from table2 where 分院 = '" & department & "' ";  
    ->
    String sql="select * from table2 where 分院 = '" + department + "' ";
      

  3.   

    sorry. scarab(没有尾巴的鲨鱼) 是对的。手误。
    不是你说的错误:
     分院  为数据库中一表的列名,数据类型是char;
       department  为string
    你的代码还没有执行,是编译出错,怎么会与数据库有关呢?