bool型数据怎么写入到bit的数据库字段中?

解决方案 »

  1.   

    提示:列名 'False' 无效
      

  2.   

    你不会是在那个值上加了单引号吧..
    如果加了就去掉
    否则把你的Sql语句发出来看看 
      

  3.   

     public bool Xnosql(bool B)
    {
    ...
    string sql = "update wupin set youwu="+B+"";
    ...
    }
      

  4.   

     1:
     public   bool   Xnosql(bool   B) 

    ... 
    string   sql   =   "update   wupin   set   youwu='"+B+"'"; 
    ... 

    2:
     public   bool   Xnosql(bool   B) 

    int i=0;
    if(B)
    {
     i=1;

    string   sql   =   "update   wupin   set   youwu="+i+""; 
    ... 
    }
      

  5.   

    1: 
      public       bool       Xnosql(bool       B)   
    {   
    ...   
    string       sql       =       "update       wupin       set       youwu='"+B+"'";   
    ...   
    }   
    -----------------------
    提示:无法将varchar型的false插入bit列
      

  6.   

    抱歉...
    应加上单引号...
    改成相面的
    string   sql   =   "update   wupin   set   youwu='"+B+"'"; 
      

  7.   

    2: 
      public       bool       Xnosql(bool       B)   
    {   
    int   i=0; 
    if(B) 

      i=1; 
    }   
    string       sql       =       "update       wupin       set       youwu="+i+"";   
    ...   
    }
      

  8.   

    SQL中bit类型的使用:
    1。往数据库中添加,修改 bit 类型的字段时,只能用 0 或者 1。
    2。在SQL语句中也只能用   0 或者 1,比如 "where bFlag=1" 不能用 "where bFlag=TURE"。
    3。在使用RecordSet 将bit字段的数据取出来后,转换为了 Boolean 类型。这个时候判断要用 TRUE 和 FALSE。