我向数据库中插入一连串的11位数字。我是写了一个循环。
CString strBegin;//strBegin和strEnd是界面输入的。有11位数字
CString strEnd;for (long i=atol(strBegin);i<atol(strEnd);i++)
{
    ......
    m_pSet->field1.Format("%d",i);
   .....
}但是long的长度好像不能超过11位,有没有其他数据类型?
如果截取后面5位做循环,那么如果是12345699999--12345700000就没法做了。
我只能从第一位开始比较,到不相同的地方再截取做循环了。有没有什么比较方便的方法?

解决方案 »

  1.   

    你的field1是什么类型? 怎么装下十一位啊?  整型?
      

  2.   

    使用__int64呀,它是20位的;for (__int64 i=_atoi64(strBegin);i<_atoi64(strEnd);i++)
    {
        ......
        m_pSet->field1.Format("%I64",i);
       .....
    }
      

  3.   

    你的数据库如果是 SQL Server2000 ,可以定义field1 的数据类型为 BigInt
      

  4.   

    m_pSet->field1.Format("%I64",i);//是%I64吗?Format时候出错了。如果用%d出来的是负数。
      

  5.   

    行了,应该是m_pSet->field1.Format("%I64d",i);谢谢大家,等下结贴。
      

  6.   

    c/c++能识别的:__int64/ 8个字节
    从–9,223,372,036,854,775,808 到 9,223,372,036,854,775,807 double 8字节long double 10个字节
    -------------------------------------------------------
    strtod, wcstod
    Convert strings to a double-precision value.
    double strtod( const char *nptr, char **endptr );
    double wcstod( const wchar_t *nptr, wchar_t **endptr );
    -------------------------------------------------------