首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

能把32位的二进制数据存入数据库中吗

2012-10-19 
能把32位的2进制数据存入数据库中吗就是把32位的2进制1100100100等东西存入int型的字段里。我在数据库中试

能把32位的2进制数据存入数据库中吗
就是把32位的2进制1100100100等东西存入int型的字段里。
我在数据库中试了。好像不行。。那怎么办

[解决办法]
varchar
[解决办法]
int 的类型 改为bigint 已测试 可以存进去
[解决办法]
int刚好就是32位,存不进去才怪了,当然了,你用字符串"1010101"是不可能存进去的
[解决办法]
32位,不正好是一个Int32嘛

C# code
using System;class App{    public static Int32 _Signin;    public static Int32 GetSignin(Byte index)    {        return (Byte)(_Signin >> index & 1);    }    public static void SetSignin(Byte index, Byte value)    {        if (value > 0)        {            _Signin = 1 << index | _Signin;        }        else        {            _Signin = ~(1 << index) & _Signin;        }    }    static void Main()    {        for (Byte i = 0; i < 31; i++)        {            SetSignin(i, (Byte)(i % 2 == 0 ? 1 : 0));        }        for (Byte i = 0; i < 31; i++)        {            Console.WriteLine(GetSignin(i));        }        Console.ReadKey();    }} 

热点排行