select * from tb where c_status in ('"+status+"')
status 是定义的数组,数组中我已经赋值了
这样查不出结果。。
应该怎么写呢?(我想查找 c_status符合status中值的记录,c_status是string类型的)

解决方案 »

  1.   

    String str = "";
    for(int i = 0;i < status.Length;i++)
      str += "'" + status[i] + "',";str = str.Trim(',');"select * from tb where c_status in ("+status+")"
    这样试试
      

  2.   

    select * from tb where c_status in ('"+status+"')
    =====================
    status 变量 的值按照这种格式进行付值: 'aaa','bbb','ccc'string sql="select * from tb where c_status in ("+status+")";
      

  3.   

    组织数组中的值为'xxx','xxx','xxx'形式的字符串
      

  4.   

    查询语句中的in不能直接等于数组,你可以试试1楼的方法,循环把数组拆开成“ '值', ”的格式,就OK了
      

  5.   

    设置个断点看看咯。看到status 到底值是什么,是不是有错。
      

  6.   

    断点调试,看看数组的值是否满足'XX','XX'的格式
      

  7.   

    string strRes=string.Empty;
    int i=0;
    foreach(string s in status)
    {
        i++;
        strRes+=s;
        if(i<status.length-1)
        {
            strRes+=",";
        }
    }
    select * from tb where c_status in ('"+strRes+"')